By Pavel Polityuk and Natalia Zinets
KYIV (Reuters) - At the outbreak of the war in eastern Ukraine in 2014, the Ukrainian army was so poorly equipped that ordinary citizens were knitting socks, donating scrap metal and even crowdfunding a tank for soldiers at the front line.
The government that took over after the Maidan street protests said it had only 5,000 combat-ready ground troops and did not put up a fight when Russian forces seized and annexed the Crimea peninsula in March that year.
But the Crimea annexation and seven years of fighting Russian-backed forces in the eastern Donbass region drove Ukraine to overhaul its military, combining a huge increase in defence spending with aid and training from Western allies.
Rising tensions over a Russian troop build-up on Ukraine's eastern border have prompted President Volodymyr Zelenskiy's administration to lobby Western governments to speed up the ex-Soviet state's entry into the NATO military alliance.
While Ukraine's army is still outgunned by Russia, the cost of Russia launching an offensive into Ukrainian territory could be significantly higher now.
"Russia will not get a quick victorious 'war,' but the losses on both sides in the event of escalation of aggression will be huge," said Mykola Sunhurovskyi, a defence analyst at the Razumkov Centre think tank.
State spending on security and defence has climbed to nearly 6% of gross domestic product this year and averaged more than 5% in the past three years, according to finance ministry data, compared to 2% in 2014.
The military has nearly 250,000 troops, compared to 168,000 in 2013.
The government has acquired new hardware to gradually replace the Soviet-era arsenal that the army relied on in 2014. It acquired Javelin anti-tank missiles from the United States and Turkish combat drones that helped Azerbaijan defeat ethnic Armenian forces in and around Nagorno-Karabakh last year.
Though Ukraine's military was dogged by corruption scandals in the past, the government has also implemented reforms backed by NATO to improve its eligibility for membership, such as passing a draft law to reform its security services in January.
(Writing by Matthias Williams; Editing by Cynthia Osterman)