Allawi (left) and Maliki, always the best of mates

IRAQ'S politicians were poised, as The Economist went to press, to take their biggest step, since an inconclusive election eight months ago, towards finally getting a new coalition government. Nuri al-Maliki, the incumbent prime minister, looks set to stay on. The presidency, a largely ceremonial job, seems likely to go again to the Kurds, perhaps also to the incumbent, Jalal Talabani. And the party led by Iyad Allawi, a secular Shia backed strongly by Sunnis, which narrowly won the most seats in the election in March, will probably get the post of parliamentary speaker, the chair of a new security council, and perhaps the foreign ministry too. If parliament endorses this package, Mr Maliki will have 30 days to allot the entire gamut of ministries. An actual government is not yet in place; last-minute hiccups may yet occur. But a new balance of power, not all that different from the previous one, is emerging. The debilitating vacuum of the past eight months should at last be filled.

The arrangement will stick in many Iraqi gullets. Mr Maliki is unloved, especially by Sunnis and by many Kurds. Sunni Arab leaders of neighbouring countries distrust him. Since becoming prime minister in May 2006 as a compromise figure, he has used his term of office to tighten control of the security forces. The new security council, to be run by Mr Allawi and his Iraqiya party may in theory clip Mr Maliki's military wings. But no one knows how it will operate. “Council shmouncil,” says Joost Hiltermann of the International Crisis Group, a Brussels-based outfit. “It doesn't exist yet.”

However the package is dressed up, Mr Maliki has ended up on top and Mr Allawi below. Most Sunnis still feel vehemently, since their group won more seats than any other (91 out of 325 to Mr Maliki's 89), that Mr Allawi should have become prime minister. But there will be widespread relief that Iraqiya has apparently agreed to take part in government at all. Its refusal would have left Sunnis feeling disfranchised and more sympathetic to the jihadists still afflicting the country, especially Baghdad. Sunni insurgents probably linked to al-Qaeda have recently perpetrated a string of spectacular atrocities.

Two other features of the negotiations are striking. First, the Kurds have kept their role as kingmakers and may have insisted on giving Mr Allawi's team a powerful presence in government. At one stage it looked as if it might not have a role at all.

Second, Iran's influence, though far from dominant, has grown. In particular, the government in Tehran may have pressed Mr Maliki to include Muqtada al-Sadr, a populist anti-Western Shia cleric, in the new coalition. Two-and-half years ago Mr Maliki successfully sent in the army to crush Mr Sadr's militias in the southern city of Basra. So Iran will have an array of friends running the show in Baghdad.