Iraqis disagree about many things but on one topic they are united: they believe they live in the most corrupt country in the world, barring a few where there is nothing much to steal. They see themselves as victims of a kleptomaniac state where hundreds of billions of dollars have disappeared into the pockets of the ruling elite over the past 15 years, while everybody else endures shortages of everything from jobs and houses to water and electricity.

The popular rage against the political class that came to power in 2003 explains why the movement led by the populist-nationalist cleric Muqtada al-Sadr, which demands political and social reform and is allied to the Iraqi Communist Party, topped the poll in the parliamentary election in May. But the low turnout of 44.5 per cent underlined a conviction on the part of many that nothing much is going to change, whatever the makeup of the next government – something still being patched together in snail’s pace negotiations between the parties. “Even friends of mine who did vote are disillusioned and say they will not vote again,” one Baghdad resident told me.

It is impossible to exaggerate the frustration of Iraqis who know they live in a potentially rich country, the second largest oil producer in Opec, but see its wealth being stolen in front of their eyes year after year.

I was in Ramadi, the capital city of the province of Anbar, west of Baghdad, looking at the war damage when I met Muthafar Abdul Ghafur, 64, a retired engineer who had just finished rebuilding his house which had been destroyed in an airstrike. “I did it all myself and got no compensation from the government,” he said, adding bitterly that some whose houses were largely intact had received compensation because, unlike him, they bribed the right officials. “Write that Iraq has no government!” he shouted at me. “It has only thieves!”

Back in Baghdad, I visited the upper middle-class districts of Mansour and Yarmouk to talk to a real estate dealer, Safwat Abdul Razaq, who said he was doing good business. The price of property in this area had doubled in the past two years, but he was less optimistic about the future because of the weak government and, above all, because of the pervasive state corruption. “The government has no credibility,” he said. “Wherever you go, they ask you for a bribe.”

He added that a contractor invariably had to pay off officials to win a contract and one of the three businessmen sitting in the office said that this could easily be 50 per cent of the contract price. There was plenty of private money in Iraq but little of it was invested there because corruption made any business activity insecure: “that is why I buy property in Jordan but not in Iraq.”

These are well-off people, but I heard the same complaints in the Shia working-class stronghold of Sadr city, where heaps of rubbish lie uncollected in the streets. “The young people are a lost generation, who can’t afford to get married because they have no jobs and no prospects unless they know somebody in the government,” said a local paramilitary. Water and electricity were in short supply and expensive to buy privately.

Grotesque examples of official theft have been frequent since a new class of leaders, mostly Shia and Kurdish, took power in Iraq after the US invasion. When the Iraqi government was supposedly fighting for its life militarily in 2004-2005, the entire $1.3bn (£980m) military procurement budget disappeared. A few years later, police at checkpoints in Baghdad were trying to detect car bombs with a useless device that cost a few dollars to make and which the government had bought for tens of thousands.

How did successive Iraqi governments get away with such blatant thefts for so long? For years they diverted attention away from their looting of Iraq’s oil revenues by claiming that the struggle against al-Qaeda in Iraq and later Isis was the only thing that mattered. They appealed to the sectarian solidarity of the Shia and, in northern Iraq, to the ethnic solidarity of the Kurds.

But a year after Isis suffered a decisive defeat in the siege of Mosul, these excuses no longer work. Security is better than at any time since the fall of Saddam Hussein, so Iraqis are more conscious than ever before of the failings of a parasitic leadership and a semi-functional state machine.

A word of caution here: Iraqis like to think of their country as uniquely cursed by corruption with billions of dollars paid to shell companies for projects in which not a single brick is placed on top of another. But Iraq is not alone in this, since all the states whose wealth is drawn entirely from the exploitation of their natural resources – usually oil – operate similarly. In each case, members of a predatory ruling elite – from Angola to Saudi Arabia and Iraq – plug into state revenues and grab as much as they can get their claws on.

Obscenely excessive expenditure by the ruling circles in these countries is notorious, but they are not the sole beneficiaries. All these resource-rich states have vast patronage systems whereby a large chunk of the population gets jobs, or receives salaries, though no work may be necessary. Iraqis and Saudis may denounce corruption at the top but millions of them have a stake in the system, which gives it a certain stability. In Iraq, for instance, some 4.5 million Iraqis work for the state and these are the plum jobs that others would like to have. Though political leaders in Baghdad talk about reforming this system, it is politically dangerous to do so because the networks of corruption and patronage established themselves too long ago and involve too many powerful people and parties.

“Anti-corruption campaigns” – in Iraq as in Saudi Arabia – are often just one group of super-rich trying to displace another. The patronage system is the only way that many Iraqis and Saudis get a share of the oil revenues and they will resist being deprived of this in the supposed interest of creating a more functional system.

In Iraq the mechanics of corruption operate in a slightly different way than elsewhere because of the role of the political parties. Mudher Salih, a financial adviser to the prime minister Haider al-Abadi, told me that “unless the political system is changed it is impossible to fight corruption”. He said that the reason for this is that parties use the government ministries they control as cash cows and patronage machines through which they sustain their power. This way of doing things is probably too ingrained, and in the interests of too many people, to be radically changed.

Corruption cannot be eliminated in Iraq, but it can be made less destructive. When al-Abadi became prime minister in 2014 Isis was advancing on Baghdad and oil prices were well. Salih said that in response to the crisis the government “cut expenditure by 37 per cent by removing ‘fishy’ items – money being spent for nothing at all”. Corruption will stay, but in future Iraqis can at least hope to get something for their money.