“We came in naïve about what the problems were in Iraq,” Gen. Raymond Odierno, the American military commander in Iraq, told me last August, a few days before he was to end his third tour. He had spent four years in Iraq. “I don’t think we understood what I call the societal devastation that occurred, we didn’t realize how damaged Iraq had been from 1980, in the Iran-Iraq war.” The list went on: Iraq’s 1990 invasion of Kuwait, the 1991 gulf war, international sanctions that crippled Iraq’s middle class. “And then,” Odierno added, “we attacked to overthrow the government.” The same naïveté affected American efforts to mold Iraqi politics, with its ethnic and sectarian divisions. “We just didn’t understand it,” Odierno said.

I asked him if the United States had made those divisions better or worse. “I don’t know,” he said, with what felt like sincerity. “There’s all these issues that we didn’t understand and that we had to work our way through. And did maybe that cause it to get worse? Maybe.”

As the U.S. completes its drawdown of military forces in Iraq, the country is solidifying its own sectarian and ethnic divisions — the culmination of a process that began with the invasion in 2003. Not that these divisions are new in Iraq. They simmered even as the country was created after World War I and assumed stark form under Saddam Hussein. He ruled by empowering members of his own Sunni tribe; he waged a genocidal war against Iraq’s Kurds in the north and crushed an uprising among the Shiite majority in the south. But after deposing Hussein and the Baath Party, the U.S.-led Coalition Provisional Authority constructed something unprecedented: a political system that ignored class, nationalist and other dynamics in favor of a simple calculus of Sunni, Shiite and Kurd.

Whether that system will become permanent was tested last year. The national parliamentary elections in 2010 were supposed to give Iraqis a solid basis on which to retake control of their country. The leading parliamentary lists were headed by two familiar names: Ayad Allawi and Nuri Kamal al-Maliki. Allawi was a secular Shiite from an elite family, a burly man, born in 1945, who was active in Saddam Hussein’s Baath Party until he fell out with the leader and went abroad in 1971. Based in London, Allawi devoted himself to shadowy exile politics, leading a group called Iraqi National Accord and cultivating ties with the Central Intelligence Agency and Britain’s MI6, all aimed at the eventual overthrow of Hussein. Nuri al-Maliki was a very different person: a Shiite believer from relatively humble origins, five years younger than Allawi, whose political career depended on advancing Shiite interests. He fled Iraq in the late 1970s after being sentenced to death. In exile, he toiled with the Shiite Dawa Party, an Islamist group that he joined as a college student in 1970 and that Hussein outlawed. Maliki built relationships with Syria and Iran. He was chosen as prime minister in 2006 on the assumption that he would be a weak and malleable leader, but he proved to be both an able schemer and ruthless when he needed to be, including in the use of military force. After four years in office, he was by far Iraq’s most powerful politician. In the 2010 elections, Maliki led, in essence, the Shiite list, aimed at advancing the interests of the Shiite majority, while Allawi led a more diverse set of parties and politicians with a broad commitment to a secular future for Iraq.

Allawi won, barely. But then this fragile secular victory began, slowly and over a period of months, to fall apart. As America withdraws, Iraqis are left to wonder why their tentative democracy has come down to this, and whether some better future might still be possible.

The vote on March 7, 2010, began with a barrage of blasts in Baghdad and other cities and ended before nightfall. Even in Falluja, a town long synonymous with the insurgency, scratchy loudspeakers that once carried messages urging resistance to the American occupation now implored residents to defy the bombs and vote. To a remarkable degree, they did, and for the first time in post-Hussein Iraq, the country could claim to have a relatively representative national vote, free of boycotts.

When the results were finally tallied, Allawi’s list won 91 seats, the most in Parliament. Maliki came in a close second, with 89 seats. Frustrated and angry, Maliki set about trying to reduce Allawi’s edge. “No way we will accept the results,” he vowed. He demanded a recount. He called some of the winners on Allawi’s list “terrorists held in Iraqi prisons.” Over the next two months, with his consent, a government body of dubious legality looked for candidates — disproportionately, those on Allawi’s list — to disqualify on the basis of their supposed ties to the Baath Party.

None of it mattered in the end. On June 1, after three months of legal challenges and disqualifications, Iraq’s highest court ratified the results of the election. All the wrangling failed to change a single seat. Allawi still had 91, Maliki 89. Two weeks later, Parliament convened for the first time, in an 18-minute session that would mark the Legislature’s last meeting for five months.

And so Iraq’s politicians settled into a long summer of bullying and flirting, brinksmanship and bargaining, all aimed at creating a coalition government with the minimum of 163 members needed to gain a majority in Parliament and name the next prime minister.

Maliki had the power of incumbency, which enabled him to shape the perceptions of him by the United States, his foes and the rivals he courted. The negotiations drew the interest of Turkey, Iran and every other neighbor of Iraq. Vice President Joseph Biden regularly called Iraqi officials for freewheeling conversations and visited Baghdad to try to push the process toward a conclusion. Maliki, with a disadvantage in votes but the ability to exploit his position as the sitting prime minister, wasn’t going to be hurried.

Allawi had neither incumbency nor Maliki’s political appetites and acumen, but he did have the advantage of close relationships with some of the country’s most influential politicians — from the Kurdish leader Massoud Barzani to Adel Abdul Mahdi, a leading Shiite figure whom he counts as a childhood friend. In American-sponsored polling over those months, Allawi drew far higher approval ratings than Maliki. A clear majority of Iraqis believed he had earned the right to form a government — and that a government without him would be illegitimate.

The negotiations represented the pivot not only on which Iraq’s future would turn but also on which direction America’s legacy would take. In rhetoric at least, and to his supporters who disproportionately came from Iraq’s Sunni Arab and secular segments, Allawi was the answer to all the tumult the Americans unleashed and began institutionalizing with the tragicomic reign of L. Paul Bremer III as American proconsul in 2003 and 2004. He captured the nostalgia for a time — preinvasion, and to some degree pre-Hussein — when asking whether someone was Sunni or Shiite was ill mannered, even insolent. There were, after all, more subtle ways to figure it out.

Allawi’s promise was that he would swing the pendulum back to this bygone Iraq. “I was raised in a different way,” he told me in one of our first conversations. Born to a wealthy Shiite family, Allawi was never in need. His father was a doctor and a member of Parliament; his mother hailed from Lebanon’s Osseiran family, one of the most prominent clans in that country. (“A decent background,” Allawi says nonchalantly.) His Baghdad was a different city: fashion on River Street and culture on colonnaded Rashid Street, with its restaurants and cinemas. Nearby shops offered the tastiest pastries, the best coffee and the most delicious ice cream. Officials, sheiks and men of letters chatted at the Parliament Cafe. Allawi has a picture hanging in his home of Rashid Street circa 1937.

This is the stuff of nostalgia, in which Iraq is remembered as a far more pleasant place than it ever was. Allawi doesn’t engage in too much of it — he’s not a sentimental man — but he does speak to what it represents: an ideal that preceded war with Iran in the 1980s, the American-backed sanctions or the staccato bursts of invasion, occupation and civil war.

“I said I used to come as a child to Najaf with my family, and one of the protocols of going to Najaf was to visit your father,” he said, recounting a conversation a few years ago with Abdul Aziz al-Hakim, father of an influential Shiite leader and the son of an ayatollah, Mohsen al-Hakim, once the most powerful in Iraq. “We saw Christians, Sunnis, Shiites in his house. So I asked him, why does it have to be different now?”

That ideal — as much a narrative of class as of sect — is heard especially from members of the diaspora that inhabits Syria, Jordan and the West. One of them is Faruq Ziada, a Baghdadi I met during the 2003 invasion. He left the country in 2006, and in our last conversation he darkly suggested that his departure, along with that of hundreds of thousands of Iraqis, was not coincidental but rather meant to eliminate vestiges of Iraqi secularism. “This is part of the plan,” he told me. “The plan is to get rid of all Iraqis who can think, who know what’s good and bad, to kick them all out of Iraq, so those who are ruling — what is left — are the illiterate, backward, needy, hungry and broken.”

Allawi and this diaspora represent a sense of entitlement and protest over lost privilege. His speech is arrogant and aristocratic, with little attempt at flattery. He has an opportunistic side but comes across as more sincere the longer you are with him, and it is hard to question his desire for that older, imagined Iraq where, as he put it, “an Iraqi can be a Christian, can be a Muslim, can be a Sunni, can be a Kurd, can be a Turkoman, but this guy still remains an Iraqi.” Maysoon al-Damluji, a candidate from Allawi’s list, who hails from another aristocratic family, told me that Allawi was “a civilized gentleman”: “He doesn’t have a sectarian hair on him.” For her and others — and Allawi himself — he was the best hope to, as his party put it, overturn a situation “based on sectarian quotas” that “lacks belief in real participation.”

The great problem with this vision was that it seemed always to be tugged back to a political energy source that had nothing to do with democratic participation: the one-party Baathism that brought Hussein himself to power. Allawi joined the Baath Party in the 1960s, while still in high school. Colleagues say the party was suited to him for two reasons. One was his toughness. A schoolmate at the Jesuit-run Baghdad College, Waiel Hindo, remembered him as “a fighter,” and his picture from the leather-bound yearbooks, showing a burly youth with a wry grin wearing a tie too short, says as much. “If he wanted to play handball, everybody would leave the court because they were afraid of him,” Hindo recalled. “That was Ayad Allawi.” The other quality was his social prominence, coming as he did from a well-connected Baghdad family, which proved useful in springing him from jail in the years of plotting before the Baath Party, with young Allawi’s help, returned to power in 1968.

Allawi says he had a falling out with Hussein and other Baathist leaders in 1970. He made his way to London, where he studied medicine and, in time, was reportedly contacted by British intelligence, which later introduced him to the Central Intelligence Agency. Some of his critics contend he was still working with the party abroad in those years, as an intelligence operative. But by 1975, he had clearly cut his ties with the party for which he had worked for a decade and a half. Three years later, he managed to survive an attempt on his life in London, for which he blamed Hussein. As with other Allawi stories, the details differ each time he tells them. In one account, he shouts at his fleeing attackers, who nearly severed his leg with an ax, “You tell Saddam I am going to survive this, and I’ll take your eyeballs out.” To me, he said his parting words were: “If I die, I am sure that the Iraqi people will take revenge. And if I live, you will go to justice, you and Saddam.”

Allawi spent months recovering in the hospital, then kept a low profile for the next decade. He re-emerged on the public scene after the 1991 gulf war, when he led the Iraqi National Accord, which catered to former Baathists like himself and soon forged close ties to the C.I.A. After the U.S.-led invasion in 2003, he was named by Paul Bremer to the Iraqi Governing Council, a sham body even to its own members, who never really agreed on what it was supposed to do: provide cover for American occupation, or help rule a collapsing state. The following year, American officials essentially handed Allawi the position of interim prime minister. Some who worked with him at the time remember an impetuous man, authoritarian and occasionally vulgar. A former colleague tells a story of him skipping an appointment with Grand Ayatollah Ali al-Sistani in 2004 with the excuse that he had a headache. Another recounted a story that still makes the rounds: when American and Iraqi forces were fighting followers of the populist cleric Moktada al-Sadr, Allawi brushed off concerns about damaging the shrine of Imam Ali, one of Shiite Islam’s most sacred locales, with no more than a vulgar remark. (Allawi denies both these accounts.)

The image that has lingered — call it neo-Baathist — is at the heart of Allawi’s quandary. People hate Allawi because he seems like, as one resident in the neighborhood of Karada put it to me, “a second Saddam Hussein.” Then again, people like Allawi for the same reason: because he amounts to, as another resident in the same neighborhood put it to me, “Saddam without a mustache.” Unfortunately or fortunately, Allawi has it both ways. “The Baath Party won’t return to power openly, but in the shadows they could creep back in,” Abu Mustafa Ali, a burly storekeeper in Sadr City, Baghdad’s vast Shiite slum, explained to me during a day I spent there. Allawi was their agent, he told me. “Learning in youth,” he said, quoting a proverb, “is like engraving a stone.”

“Iraq was not sectarian — only now is it becoming sectarian,” Allawi told me one day in his office as the summer’s negotiations dragged on. “And the sectarianism is only among the elite, the political elite, not within the people of Iraq.” I told him what Ahmad Chalabi has said, that “sectarian politics gets votes in Iraq.”

“But is winning votes the answer to our problems?” Allawi asked.

The abstractness and pensiveness of that question suggest something of what makes Allawi an interesting person but also what makes him a frustratingly ineffectual politician. Meanwhile, Maliki was reaching out to potential allies while staying confident that the longer he lasted, the less likely a coalition without him would arise in Iraq’s distrustful, dysfunctional political climate. Maliki schmoozed and made promises to any and all, and he managed to overcome animosities that left him barely on speaking terms with key figures like Barzani, the Kurdish president.

Allawi, a man better incarnated as strongman, operative or exile, was not very good at dealmaking. He pointedly refused to answer a question about whether he trusted Maliki. “We know there are a lot of incentives being offered,” he told me in the summer, laughing, “and a lot of pressures and threats being offered and being done and made.” Maysoon al-Damluji, the spokeswoman, was blunter. I asked whether Allawi and the rest of his list were clever enough to split other alliances. “I don’t know if we are,” she admitted. “They,” she said of Allawi and his allies, “are too polite.”

Even his closest allies complained that he traveled too much (in one week, he managed to visit Qatar, the United Arab Emirates, Turkey and Britain, where his family lives for reasons of safety). As common were the complaints that he was arrogant and moody; after choosing not to join the government formed in 2006, he refused to attend a single session of Parliament. “He has sort of a superiority complex,” said a critic who was once a confidant. “He feels that he is probably the cream of the cream of politicians, and this is a tragedy if a politician has this sort of feeling.”

The most stinging words I heard during the summer were from Ryan Crocker, the former United States ambassador to Iraq. He echoed Allawi’s former confidant but was sharper about what he described as Allawi’s “reluctance to be engaged.” “Frustrating often,” Crocker called him, “sometimes almost tragic in the sense of the fatal flaw. He’s got good ideas, good instincts, but he has never really made the transition from exiled figure to indigenous politician. It’s sad, because Allawi, as much as any and more than most, I think, taps that discontent in the Iraqi population over the current trend in things. I’m just afraid he’s backing away from it.”

All of this was true, of course, but the more I spoke with Allawi, the more I wondered whether the forces arrayed against him were simply too great, even if he somehow managed to overcome his ample flaws. I wondered whether Chalabi’s remark — the idea that, in Iraq today, sectarianism wins votes — held more truth for the country that emerged after the American invasion than Allawi’s nostalgia.

It certainly was true in Sadr City. The brilliance of the movement loyal to Moktada al-Sadr, a populist cleric who holds sway in the neighborhood, is its ability to read the street. It takes pride in it, and as demagogues, its cadres can sacrifice truth for theater. There was plenty of that during the election and after, as leaflets made the rounds at the Friday prayers, where thousands gather each week. In one leaflet, Vice President Tariq al-Hashimi, a Sunni and ally of Allawi’s, was pictured over a passage that supposedly quoted him saying, “No place will be left for the Shiites to rule Iraq, even for a month.” Opponents are pictured with Ali Hassan al-Majid, the particularly bloodthirsty lieutenant of Hussein’s nicknamed Chemical Ali.

No one around here seemed to rule out the prospect of the Baath Party returning, and Abu Mustafa, the burly storekeeper, saw it as part of a grander conspiracy. It was remarkable how many people shared the sentiment. In store after store, there was a sense — even among people who were fond of Allawi, and they were not few — that, in essence, he was not one of them. However Shiite he might be, he still spoke a Sunni language.

“Ayad Allawi will take us back to what we had before,” Abu Mustafa told me, as we sat at his counter, children interrupting us to buy candy. “I was one of the people who liked him in the beginning. He was a strong man. But I see the people with him on his list and those people, very honestly, are from the Baath Party, and they’re sectarian.”

When I asked him who, he shrugged. “I can’t remember all their names.”

For Allawi’s opponents, Allawi, though Shiite, was the head of a Sunni bloc, and the Shiite majority — as understood by Iraq’s religious Shiite parties — would not permit a bloc representing the Sunni minority to name the prime minister. “This is the fundamental issue,” said Qassem Daoud, a minister in Allawi’s government who ran unsuccessfully on a rival list. “No one in the Shiite community would accept it.”

The very definition soon became a fierce point of contention since each side knew the import of the symbolism. To be a secular bloc made Allawi’s list more nationalist and hence more palatable; to be Sunni made it merely one constituency among three, and a junior one at that. Both interpretations were plausible. It would be the American Embassy’s reading that would prove decisive.

By the end of the summer, as Christopher R. Hill ended an unmoored 16 months as American ambassador here, it had become clear where the U.S. stood. The embassy makes a point of no longer stage-managing Iraqi politics — the way, say, Zalmay Khalilzad did as ambassador from 2005 to 2007, when he would show up unexpectedly for breakfast with politicians and banter with clerics in Persian. “We don’t want to give the impression that we’re picking winners and losers,” says James F. Jeffrey, Hill’s successor as ambassador. But even if times had changed, there was still the perception of decisive American influence, and even as Allawi told me, perhaps tongue in cheek, that he was “still very optimistic” about becoming prime minister, American officials were saying otherwise, particularly in private. In essence, they accepted the argument of Maliki and other religious Shiite leaders: that Allawi represented the Sunni bloc. Though there was some dissent, the embassy did little to suggest it thought otherwise in those crucial summer months, and as long as Allawi was perceived as the candidate synonymous with Sunni restoration, he could not win.

The last gasp was an effort by Allawi’s list to throw its support behind a compromise candidate, Allawi’s childhood friend, Adel Abdul Mahdi. But the stars never aligned, and in one of our interviews, Allawi complained bitterly that the opportunity was missed. “He didn’t push at all, not hard enough, not at all,” he said of Abdul Mahdi. “No, no, he was sitting, waiting for everybody to do the work, and this is not right, you know. It’s something which should have happened.” It was the very same critique that virtually everyone made of Allawi himself.

By October, Maliki seemed a sure thing to return to power, Allawi’s support within his own list began to crumble and the recriminations started. “I don’t know what really the attitude of the United States is and why,” Allawi told me just before Maliki’s triumph became clear. “I can understand why Iran is saying, ‘We don’t accept Allawi.’ This is to me quite clear. But with the United States, I really don’t know. Although they say they are not taking part and they are not taking sides, the fact remains that the prime minister is encouraged, it seems to me, by — at least I would put it this way, no one is telling him to transfer peacefully power and to work with others.”

One senior Western diplomat suggested the negotiations had become a souk in the end — “what are you selling and what’s the price,” as he described it. Indeed, in the ensuing week, as Maliki’s writ looked more and more permanent, many on Allawi’s list — most of whom never really got along with one another — went their own way and struck their own deals with the prime minister. There was no shortage of cynicism, as the spoils were divided, in a game that Kamal Kirkuki, the candid Kurdish Parliament speaker, may have captured best. I asked him why the Kurds would back Maliki, whom they long disliked, over Allawi, with whom they have enjoyed a long relationship. I expected him to say something about some of Allawi’s allies — ardent Sunni Arabs and nationalists whose rhetoric often sounds anti-Kurdish and chauvinist. He didn’t. “If you have two people, and one of them is promising but lying to you and the other is refusing to promise anything,” he explained to me, “you will still prefer the first.”

Maliki’s victory ended eight months of utter political dysfunction, and what have become Iraq’s key players were all represented in some fashion. “A big step for Iraq” is how an American briefing paper described the result. “A government that is made in Iraq.” Former American diplomats were less encouraged. Before it had all finished, Crocker offered a typically insightful prediction. “There will be a little for everybody, probably,” he said. “It’s going to be fairly inclusive among the elite. But the promises that are made, the deals that are dealt, are really not going to involve any promises or commitments to make life better for people in Iraq. That’s just not what the transaction is in Iraqi politics.”

Effectiveness, in other words, was sacrificed for consensus, or as the briefing paper had it, “the first truly inclusive and cross-sectarian government.” The only problem is, it could easily be argued that this was the first truly sectarian government, making permanent those inchoate forces that Odierno mentioned. Allawi represented a step back from a system that, simply put, has little concept of equal rights, no tendency toward secularism and no notion of a broader nation. The election in March offered the best, and maybe the last, chance to provide an alternative construct to the ethno-sectarian model whose best example is the very troubled state of Lebanon. The opportunity was missed because of assumptions deemed truths, ensuring that a prewar cliché of 2003 became reality in 2010.

As Allawi’s cousin, Ali Allawi, an incisive author and former government minister, put it to me, “Whether we like it or not, this will likely be the division of power in Iraq for some time.” The senior Western diplomat described it another way: “You end up with sectarian politics, and I just don’t know how you break out of it.”

In my first interview with Allawi, back in May, he offered a suggestion, with a laugh. “This is my advice to you — go and ask President Bush how Iraq is going to get out of this mess. Bush, Bush, your Bush, Bush Jr., you ask him. He’ll probably have the right answer. I think so. He introduced the de-Baathification, he introduced the dismantling of the army, he introduced the sectarian quotas in the Governing Council. He should know what he did — the process, how this process is going to move forward.”

By the last interview, in November, it was clear Iraq had still not got out of the mess. “Look, I carry two burdens,” he said. “I was a member of the Baath Party, I was a medical student when the change took place in Iraq and the Baath Party came to power. After a year, a year and a half, I felt guilty because I participated in the change.

“The second time,” he went on, “when we were in the opposition, we dreamed of changing the regime, going to the ballot boxes for the Iraqi people to choose their leaders and enjoying the rule of law, a real, proper rule of law, equality among Iraqis. Exactly the opposite was done.” The opposition, he said, along with what he called “a blurred vision of the United States, has created, has exaggerated the creation of Sunni, Shiite and Kurd.”

I asked which was better — the Iraq of Saddam Hussein or the Iraq of today. He shook his head with the disdain of an expatriate. “The only difference is that we have this democracy.” He uttered the word with contempt.