The Iraqi prime minister has fired dozens of top officials after the government uncovered an estimated 50,000 "ghost soldiers" on the military payroll.

Haider al-Abadi "retired" on Monday at least 24 senior Interior Ministry officials as part of government restructuring, saying that the scheme has drained millions of dollars from the country's coffers.

He said he was saddened that the government was paying out salaries to false names "at a time when we don't have enough money".

"We have soldiers fighting and being killed, while there are mock names of soldiers receiving salaries," he lamented.

There are 800,000 soldiers in the Iraqi army, and more than half a million of them are reservists, leaving less than 300,000 soldiers on active duty.

Each soldier earns about $600 a month, so the 50,000 ghost soldiers, which is equivalent to almost four military divisions, could be costing Iraq at least $380m a year.

Abadi's spokesperson Rafid Jaboori said that the investigation started with a thorough headcount during the latest salary payment process.

The US, which occupied the country for eight years, has spent billions of dollars training and equipping Iraq's military.

Since taking office in September, Abadi has sacked or retired several top military commanders, and Sunday's announcement suggests he wants to tackle the graft and patronage that prevailed under his predecessor Nouri al-Maliki.

The Islamic State of Iraq and the Levant (ISIL) group stormed through northern Iraq in a 48-hour offensive in June, charging virtually unopposed towards the outskirts of Baghdad, humiliating the Iraqi army which surrendered both land and weapons as it retreated.