'It reminds me of Iraq under Saddam," a militant opponent of Saddam Hussein said angrily to me last week as he watched red-capped Iraqi soldiers close down part of central Baghdad so the convoy of Nouri al-Maliki, the Iraqi Prime Minister, might briefly venture into the city.

Five years after the invasion of Iraq, the US and the Iraqi governments claim that the country is becoming a less dangerous place, but the measures taken to protect Mr Maliki told a different story. Gun-waving soldiers first cleared all traffic from the streets. Then four black armoured cars, each with three machine-gunners on the roof, raced out of the Green Zone through a heavily fortified exit, followed by sand-coloured American Humvees and more armoured cars. Finally, in the middle of the speeding convoy, we saw six identical bullet-proof vehicles with black windows, one of which must have been carrying Mr Maliki.

The precautions were not excessive, since Baghdad remains the most dangerous city in the world. The Iraqi Prime Minister was only going to the headquarters of the Dawa party, to which he belongs and which are just half a mile outside the Green Zone, but his hundreds of security guards acted as if they were entering enemy territory.

Download the new Independent Premium app Sharing the full story, not just the headlines

Five years of occupation have destroyed Iraq as a country. Baghdad is today a collection of hostile Sunni and Shia ghettoes divided by high concrete walls. Different districts even have different national flags. Sunni areas use the old Iraqi flag with the three stars of the Baath party, and the Shia wave a newer version, adopted by the Shia-Kurdish government. The Kurds have their own flag.

The Iraqi government tries to give the impression that normality is returning. Iraqi journalists are told not to mention the continuing violence. When a bomb exploded in Karada district near my hotel, killing 70 people, the police beat and drove away a television cameraman trying to take pictures of the devastation. Civilian casualties have fallen from 65 Iraqis killed daily from November 2006 to August 2007 to 26 daily in February. But the fall in the death rate is partly because ethnic cleansing has already done its grim work and in much of Baghdad there are no mixed areas left.

More than most wars, the war in Iraq remains little understood outside the country. Iraqis themselves often do not understand it because they have an intimate knowledge of their own community, be it Shia, Sunni or Kurdish, but little of other Iraqi communities. It should have been evident from the moment President George Bush decided to overthrow Saddam Hussein that it was going to be a very different war from the one fought by his father in 1991. That had been a conservative war waged to restore the status quo ante in Kuwait.

The war of 2003 was bound to have radical consequences. If Saddam Hussein was overthrown and elections held, then the domination of the 20 per cent Sunni minority would be replaced by the rule of the majority Shia community allied to the Kurds. In an election, Shia religious parties linked to Iran would win, as indeed they did in two elections in 2005. Many of America's troubles in Iraq have stemmed from Washington's attempt to stop Iran and anti-American Shia leaders such as Muqtada al-Sadr filling the power vacuum left by the fall of Saddam Hussein.

The US and its allies never really understood the war they won that started on 19 March 2003. Their armies had an easy passage to Baghdad because the Iraqi army did not fight. Even the so-called elite Special Republican Guard units, well-paid, well-equipped and tribally linked to Saddam, went home. Television coverage and much of the newspaper coverage of the war was highly deceptive because it gave the impression of widespread fighting when there was none. I entered Mosul and Kirkuk, two northern cities, on the day they were captured with hardly a shot fired. Burnt-out Iraqi tanks littered the roads around Baghdad, giving the impression of heavy fighting, but almost all had been abandoned by their crews before they were hit.

The war was too easy. Consciously or subconsciously, Americans came to believe it did not matter what Iraqis said or did. They were expected to behave like Germans or Japanese in 1945, though most of Iraqis did not think of themselves as having been defeated. There was later to be much bitter dispute about who was responsible for the critical error of dissolving the Iraqi army. But at the time the Americans were in a mood of exaggerated imperial arrogance and did not care what Iraqis, whether in the army or out of it, were doing. "They simply thought we were wogs," says Ahmad Chalabi, the opposition leader, brutally. "We didn't matter."

In those first months after the fall of Baghdad it was extraordinary, and at times amusing, to watch the American victors behave exactly like the British at the height of their power in 19th-century India. The ways of the Raj were reborn. A friend who had a brokerage in the Baghdad stock market told me how a 24-year-old American, whose family were donors to the Republican Party, had been put in charge of the market and had lectured the highly irritated brokers, most of whom spoke several languages and had PhDs, about the virtues of democracy.

There was a further misconception that grew up at this time. Most Iraqis were glad to be rid of Saddam Hussein. He had been a cruel and catastrophically incompetent leader, who ruined his country. All Kurds and most Shia wanted him gone. But it did not follow that Iraqis of any description wanted to be occupied by a foreign power.

Later President Bush and Tony Blair gave the impression that overthrowing the Baathist regime necessarily implied occupation, but it did not. "If we leave, there will be anarchy," friends in the occupation authority used to tell me in justification. They stayed, but anarchy came anyway.

In that first year of the occupation it was easy to tell which way the wind was blowing. Whenever there was an American soldier killed or wounded in Baghdad, I would drive there immediately. Always there were cheering crowds standing by the smoking remains of a Humvee or a dark bloodstain on the road. After one shooting of a soldier, a man told me: "I am a poor man but my family is going to celebrate what happened by cooking chicken." Yet this was the moment when President Bush and his Secretary of Defence, Donald Rumsfeld, were saying that the insurgents were "remnants of the old regime" and "dead enders".

There was also misconception among Iraqis about the depth of the divisions within their own society. Sunni would accuse me of exaggerating their differences with the Shia, but when I mentioned prominent Shia leaders they would wave a hand dismissively and say: "But they are all Iranians or paid by the Iranians." Al-Qa'ida in Iraq regarded the Shia as heretics as worthy of death as the Americans. Enormous suicide bombs exploded in Shia marketplaces and religious processions, slaughtering hundreds, and the Shia began to hit back with tit-for-tat killings of Sunni by Shia militia death squads or the police.

After the Sunni guerrillas blew up the Shia shrine in Samarra on 22 February 2006, sectarian fighting turned into a full-blown civil war. Mr Bush and Mr Blair strenuously denied that this was so, but by any standard it was a civil war of extraordinary viciousness. Torture with electric drills and acid became the norm. The Shia Mehdi Army militia took over much of Baghdad and controlled three-quarters of it. Some 2.2 million people fled to Jordan and Syria, a high proportion of them Sunni.

The Sunni defeat in the battle for Baghdad in 2006 and early 2007 was the motive for many guerrillas, previously anti-American, suddenly allying themselves with American forces. They concluded they could not fight the US, al-Qa'ida, the Iraqi army and police and the Mehdi Army at the same time.

There is now an 80,000 strong Sunni militia, paid for and allied to the US but hostile to the Iraqi government. Five years after the American and British armies crossed into Iraq, the country has become a geographical expression.

'Muqtada al-Sadr and the Fall of Iraq' by Patrick Cockburn is published next month by Faber & Faber