Iraq has uncovered the existence of 50,000 "ghost soldiers", Prime Minister Haider al-Abadi has said, promising a crackdown on corruption.

"The prime minister revealed the existence of 50,000 fictitious names" in the military, said a statement from Abadi's office on Sunday after a session of parliament.

A parliament statement said the premier scrapped the 50,000 jobs, equivalent to almost four full army divisions.

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

"There are two kinds of 'fadhaiyin'," one experienced officer in the security forces said, using a word which, literally translated, means "space men", and refers to the fictitious soldiers crowding the payroll.

"The first kind: each officer is allowed, for example, five guards. He'll keep two, send three home and pocket their salary or an agreed percentage," he told the AFP news agency.

"Then the second and bigger group is at the brigade level. A brigade commander usually has 30, 40 or more soldiers who stay at home or don't exist," the officer said.

"The problem is that he too, to keep his job as a brigade commander, has to bribe his own hierarchical superiors with huge amounts of money," he said.

The officer explained that, for those reasons, the thousands of soldiers who defected or were killed this year across Iraq were rarely declared as such.

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 armed 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.