noun
struggling; floundering; pawing
Refers to desperate physical or mental struggling, often in a hopeless situation. Also used for animals pawing the ground. The kana form is standard.
彼のあがきも虚しく、チームは負けてしまった。
His desperate struggling was in vain, and the team lost.
馬が門の前であがきをしている。
The horse is pawing at the ground in front of the gate.
もがく is the verb 'to struggle, to writhe', while あがき is the noun form of あがく, which is similar but often implies a more frantic, last-ditch effort.
Derived from the verb あがく (to struggle, to paw). The kanji 足掻く literally means 'foot scratching', reflecting the original physical sense.