If you blinked, you missed it, but the democratically elected Islamist government of an Arab country just promised to resign peacefully, with no threat of a coup d’etat in sight.

Tunisia is still a long way from political stability. Yet once again, the nation that started the Arab Spring is showing the rest of the region how it’s supposed to be done. Reasonable people facing deep disagreements are negotiating and power-sharing their way to the Holy Grail of legitimate constitutional democracy.

Start with the deal. Ennahda, the Islamic democratic party that formed a government after Tunisia’s free elections in 2011, didn’t agree to step down for nothing. In exchange for agreeing to resign in favor of a caretaker government of nonpartisan technocrats, Ennahda got the opposition to agree to ratify a draft constitution that has been painstakingly drafted and debated over the last year and a half.

Under the rules of the road, adopted after the old regime fell in January 2011, the constituent assembly can approve the constitution if two-thirds of its members vote in favor. That structure put a premium on consensus, the political value most valued by Tunisian political culture. It also put Ennahda in a tough position during the drafting process: Its slight coalition majority in the assembly gave it almost no leverage, because it needed lots of opposition votes to get to two-thirds. The only alternative was to go to the public, which might have approved the constitution by a bare majority. But that would have violated the goal of consensus, and Ennahda consistently refused to treat it as an option.

Egypt’s Errors

A culture of consensus is usually a curse for an elected majority -- but in Tunisia, it’s turned into a blessing. Instead of distrusting the opposition and trying to ram through its proposals, the way the Muslim Brotherhood tried to in Egypt, the Tunisian Islamic democrats have compromised from the start. Former Egyptian President Mohamed Mursi, convinced (correctly, to be sure) that the Deep State wanted him out, failed utterly to include independent secularists in his government. He became so focused on the fact that a majority of the public had elected him that he forgot that it hadn’t taken a majority to bring down his predecessor, the dictator Hosni Mubarak -- just the potent combination of millions in the streets and a restive Army. Attempting to govern without broad-based support, he found himself hamstrung, thwarted and, eventually, alone.

In Tunisia, the government has been very attuned to the precariousness of its mandate. When secularists opposed putting Shariah into the constitution, Ennahda fumed -- then agreed. When a prominent secularist politician was assassinated in February 2012, Ennahda sought to distance itself from the radicals who carried it out -- but its own prime minister resigned in a show of contrition for failing to prevent it.

More recently, after the assassination of a second secularist leader in July, the Islamic democrats faced their deepest challenge yet. Secular opponents were buoyed by outrage at the killing and widespread frustration with an economy that still hasn’t turned around. Sensing that the tide was turning, the opposition essentially decided to block the constitution.

In crisis, Ennahda made an extraordinary decision: It would put the secular constitution it had helped draft ahead of its party interests. A starker contrast to Morsi’s Muslim Brotherhood could hardly be imagined. Where Morsi forced a hastily drafted, highly religious constitution through a badly fractured assembly, only to see himself ousted, Ennahda put principle first. Offering to resign not only staked the moral high ground, but also foreclosed any threat of removal by force. There’s no point in plotting a coup against a government willing to step down of its own accord.

Electoral Test

The obvious gamble Ennahda is taking might be imaginable in other regions: The government is effectively calling for new elections in a few months and hoping that the public respects its success in getting a constitution through and its modesty in putting itself up to the electoral test. But this is the Arab world we’re talking about. When was the last time power was transferred peacefully in a sovereign Arab state through free and fair elections? That would be, uh … oh yeah: never.

Ennahda is staking everything on the hope that Tunisia is going to become the first Arab democracy worthy of the label. Will the gamble pay off? If it does, the reason will be precisely the Tunisian norm of consensus and Ennahda’s realization that it must respect it.

In new democracies, it can be hard to avoid the temptation to mistake an electoral majority for the capacity to rule. But majorities don’t make democracy work. Alternating governments do. The secret sauce of democracy is no secret at all. The opposition must believe that it will someday have a chance to govern, and the majority must have the same expectation. Then, with luck, self-interest will prevail, and the majority of the moment will treat the opposition with respect in the hope and expectation of receiving the same treatment when it goes out of power.

By compromising on a constitutional draft and offering to resign, Tunisia’s moderate Islamists have done their part. What remains now is for the secularists to do the same, and not to repress Ennahda when they eventually get the chance. Fingers crossed.

(Noah Feldman, a law professor at Harvard University and the author of “Cool War: The Future of Global Competition,” is a Bloomberg View columnist. Follow him on Twitter at @NoahRFeldman.)

To contact the writer of this article: Noah Feldman at noah_feldman@harvard.edu.

To contact the editor responsible for this article: Tobin Harshaw at tharshaw@bloomberg.net.