At this crucial juncture in the Middle East, the United States should propose to Baghdad the creation of a formal, treaty-based alliance. It could be modeled after America's alliances in Europe and East Asia, and include a clause like that of Article V in the NATO and U.S.-Japan charters that commits the two countries to the defense of each other. The overarching immediate purpose of such an alliance would not be to fend off foreign threats to Iraq, of course, but to help it confront the Islamic State in Iraq and the Levant (ISIL, otherwise known as ISIS or IS). The practical, near-term purpose would be to help give Sunnis, Shia and Kurds in Iraq the confidence to work together with each other against a common foe, knowing that the United States will help broker deals among them in the event of serious disagreements about internal power sharing. The longer-term purpose would be to partner with the region's key mixed Sunni-Shia state, a real if imperfect democracy, to promote a lasting future security order at a time of such tumult throughout the Arab world.

Forging an alliance with Iraq will strike many Americans not only as undesirable, given the saga of our nation's last decade in Iraq, but perplexing. After all, in the modern era, the United States has forged alliances with countries sharing our strong democratic values. The most recent expansions of America's alliance systems have occurred in Europe, where NATO has nearly doubled in size since the end of the Cold War as the continent's young democracies have been brought into the Western community. And Iraq, whatever its potential and whatever its importance, shares few characteristics with Slovakia or Slovenia or any other new member of NATO.

But in fact, historically, alliances have had many purposes. The promotion of democracy was only rarely one of them. More often, they were designed to accomplish specific security objectives in the face of acute threats. The U.S.-Korea and U.S.-Japan alliances were formed early in the Cold War, well before either of those countries could be described as a strong, established democracy. And of course, NATO was formed as a response to an iron curtain descending over Europe—with the pithy initial purpose summarized as keeping "Germany down, the Soviet Union out, and America in."

Indeed, the United States has been hardheaded about the purpose of alliances even more recently than in those early Cold War decades. It broke its alliance with Taiwan in the late 1970s to forge a stronger relationship with China against the Soviet Union. More recently, for better or worse, it has cozied up to President Sisi of Egypt in the interest of stability, counterterrorism and the protection of Israel's security. Whatever the virtues of individual decisions, this quick review should remind us not to be too airy-eyed when it comes to assessing America's purposes in entering into formal security commitments with other nations.

In the case of Iraq, the situation is of course acute. ISIL controls about one fourth of the country's territory. While its prospects for expanding that control substantially seem quite modest, its capacity to wreak havoc—on innocent Iraqis, captured westerners, nearby Baghdad (through bombings and assassinations), and perhaps someday Western countries themselves through terrorist strikes—gives great cause for concern.

President Obama has responded well to the challenge in Iraq since ISIL rolled into many of its major Sunni cities this past spring. He helped midwife the creation of a new Iraqi central government, deployed airpower to prevent ISIL's spread to Iraqi Kurdistan, and also used American airpower to help reclaim key Iraqi assets such as key dams in Mosul and Anbar province and to save certain vulnerable Iraqi populations from ISIL. He has now deployed some 3,000 American military personnel to Iraq. The last tranche has the capacity to partner in the field with Iraqi forces as circumstances permit—so they can plan and execute a counteroffensive to take back the Sunni Arab swaths of Iraq from ISIL and thereby ultimately help defeat this horrible and dangerous organization.

Alas, those circumstances do not look so promising right now. Prime Minister Abadi's government is better than the predecessor regime under Nouri al-Maliki, to be sure. But in Abadi's welcome efforts to include key members of different sectarian groups, he wound up hiring some cabinet ministers with very questionable pedigrees, including strong links to Shia death squads. As such, his capacity for reaching out to Sunni leaders in the capital, the military and the provinces remains shaky at best. By most reports, Maliki and other chauvinists of one stripe or another continue to impede policies aimed at rapprochement as well.

For example, the creation of a National Guard that would allow Sunnis (and others) to be recruited, trained and deployed in their home villages and cities—a very good idea for handling Iraq's security challenges, and a wise follow-on to the earlier Sons of Iraq program—has been held up in parliamentary intrigue. As such, the National Guard remains a concept on paper, when it is already high time to be building and training such a capability, to prepare for an already-overdue winter or spring counteroffensive.

Beyond their pro-Shia biases, Maliki and others fear that any organized Sunni armed force would have the latent capacity someday to march on the capital, overthrow the Shia-led elected government, and return the country to something like the Sunni-dominant Baathist rule experienced under Saddam. Many Sunnis in Iraq refuse to recognize their numerical inferiority vis-a-vis the Shia, or believe that their superior organizational skills (and, in their minds, their superior religion, which also tends to make them more reliably anti-Iranian) give them a natural right to run the country. In other words, the Shia paranoias are not entirely baseless.

There is only one practical solution to this problem. It is not talk of main American combat forces coming in large numbers to save the day, because we have already done that and its accomplishments could not withstand the onslaught of subsequent Iraqi sectarianism. Rather, it is the permanent commitment of the United States to the stability of Iraq, through the kind of enduring security partnership that an alliance implies. Even after the immediate crisis is solved, the United States should not be in a hurry to bring home its 3,000 (or perhaps someday 5,000 to 10,000) troops deployed in Iraq. It should retain them in Mesopotamia, partly for technical purposes of security cooperation, and partly to give Washington skin in the game of Iraq's future.

With this enduring military relationship—backing up diplomatic and economic ties as well—the United States would be in a position to cajole, persuade and sometimes even pressure Iraqis to do the right thing towards each other. The shenanigans that have characterized the country's last half-decade—including arrest warrants against respected political leaders, pogroms against competent officers in the army and extreme nepotism in the higher ranks of government—would be much harder for Iraqis of ill intent to sustain, and much easier for America to oppose, if the entire relationship were undergirded by a strong and formal alliance relationship. Determining Iraq's political future—including the possibility of some new form of confederal but still cooperative arrangement among Sunnis, Shia and Kurds—would become much easier.

Maybe a treaty to codify and solidify the U.S.-Iraqi partnership into the future is something that a new Republican Congress and President Obama could actually agree to do together over the next two years as well—assuming that Baghdad is also willing. A two-thirds Senate vote in favor of a new treaty would display a form of bipartisanship that this country badly needs—not only in general terms, but in regard to Iraq policy as well, after a decade of polarizing debate on the subject.

Of course, Iraqis would have to do their part, too—not only in agreeing to the initial idea, but in working over time towards the kind of democracy that America can be comfortable partnering with permanently. But we can be patient in pursuit of such a goal, just as we were in Korea, Japan and many other places historically as well. What we cannot be patient about is taking serious steps now to prepare the way for a major counteroffensive against ISIL. Pursuit of a U.S.-Iraqi alliance could be a key pillar in such a strategy.

Michael O’Hanlon is a senior fellow and director of research in the foreign policy program at the Brookings Institution.

Image: Flickr/Official U.S. Air Force/CC by-nc 2.0