As people in Sunni areas of Baghdad heard the full results of the election, they ran through the streets firing their rifles into the air in celebration and triumphantly chanting the name of Iyad Allawi, the leader of the political bloc winning most seats in parliament.
Mr Allawi had been expected to do well but the extent of his success is still surprising. His al-Iraqiya coalition won 91 seats in the 325-seat parliament, against 89 seats for the prime minister Nouri al-Maliki's State of Law bloc.
As interim prime minister in 2004-2005 Mr Allawi ran an administration chiefly notable for its incompetence and corruption, so his political rebirth is astonishing. It has happened because, whatever his failings then, the bloodbath that followed his rule was even worse, particularly for the Sunni community which had been ousted from power with the overthrow of Saddam Hussein.
This is Mr Allawi's strength, and his weakness. His success was the result of a massive turn-out of Sunni voters, enabling him to sweep away the opposition in the Sunni-majority provinces north and west of Baghdad. He also did well in the capital, now very much Shia dominated, which means that many Shia were attracted by his nationalist and non-sectarian platform.
But the political landscape of Iraq remains determined by sectarian and ethnic differences between Shia and Sunni Arabs and the Kurds. The strength of Mr Allawi is the backing of the Sunni, but they make up only 15 to 20 per cent of the population while at least 60 per cent are Shia and a further 15 to 20 per cent are Kurdish. For many Shia and Kurds the resurgence of the Sunni is threatening, and they will try to limit it by preventing Mr Allawi forming a government with the top jobs going to his Sunni allies.
Surprising as Mr Allawi's triumph may be, it is also something of a mirage because the Shia vote was split between Mr Maliki's State of Law and the Iraqi National Alliance (INA) which won 70 seats. The INA is made up of two Shia religious parties, the Islamic Supreme Council of Iraq and the followers of the nationalist cleric Muqtada al-Sadr. The revival of the latter, who represent the Shia poor, has been the second upset of the election.
The two big Shia blocs – State of Law and the INA – are now in talks about a merger which would give them almost half the seats in parliament. A new government would only need the addition of the 43 seats of the main Kurdish party to give them a majority. The Kurds and the INA will probably ask for a new prime minister, replacing Mr Maliki with whom both have quarrelled. The Kurds would have difficulty doing a deal with Mr Allawi because over a third of his seats are in provinces disputed between Sunni Arab and Kurd.
Iraqi politics are highly complex because there are so many players at home and abroad, none of whom trust each other. One of the reasons why negotiations to form a new government will be so long is that each side will try to lure members of opposing coalitions into their own camp by offering jobs in the government.
But the election does mark an important moment of transition in Iraq post Saddam Hussein, in which a new set of winners and losers is emerging. The good news is that the Sunni community which boycotted the last parliamentary election in 2005 have taken part in the poll, and, so long as they are not marginalised in the formation of a new government, have no reason to take up arms again. The same is true of the Sadrists, who won some 40 seats in parliament, and whose Mehdi Army militia fought the Americans in 2004 and were in the forefront of the Shia-Sunni civil war in 2006-7.
The election marks other important trends in Iraq. There is an anti-incumbency mood, understandable given the corruption and dysfunctional nature of the government. Poverty is overwhelming. No sooner was the election over than people from the slums and shanty towns of Baghdad rushed out to remove the hoardings carrying political advertisements to sell or use as roofs and walls in their own houses.
Mr Maliki ought to have done better because he controls the state machinery, with its $60bn a year in oil revenues and several million jobs. This power of patronage was not as effective as it should have been because so much of the Iraqi government is parasitic, no service being performed unless accompanied by a bribe.
Iraqis remain highly conscious of which community they belong to, though the mood is more secular and nationalist. But this growth of secularism can be exaggerated and the local authorities are closing down the remaining Christian-owned liquor stores in Shia cities such as Basra. In the final days of the campaign the Shia parties had no inhibitions about portraying Mr Allawi as a Sunni puppet. On the other hand, the vote in Baghdad, where al-Iraqiya won 24 seats and State of Law 26, shows that appeals to sectarian loyalties do not resonate as much as they once did.
What happens next in Iraq will not be decided entirely within the country. Mr Allawi's campaign was heavily financed by Saudi Arabia and other Sunni Arab states. This money will continue to provide the glue holding his disparate coalition together. The Iranians will similarly support the Shia parties coming together to form the core of a new government, though without Mr Maliki. As the American forces continue to withdraw on schedule, Iraq will remain violent and divided. But the country is not dissolving and there is less and less chance of it sliding back into full-scale war.