SINCE their back-to-back revolutions in January 2011, Tunisia and Egypt have wobbled along oddly parallel trial-and-error paths. Yet even as Egypt has blundered serially into violence and seen democracy fail, Tunisia’s trials have been largely peaceful and its democracy is still alive. Its politicians have chosen compromise over conflict, avoiding the brittle polarisation between Islamists and their critics that now so dangerously embitters Egypt.

The latest Tunisian compromise was sealed in principle on October 5th when Nahda, the Islamist party that is Tunisia’s strongest and has led a three-party coalition government for nearly two years, agreed to step down to make way for a temporary, technocrat-led administration. The details have yet to be fixed, but they include a three-week period of all-party talks leading to the formation of a caretaker cabinet, the finalising of Tunisia’s long-delayed new constitution, the revision of an electoral commission, and the holding of presidential and then parliamentary elections expected early next year.

Those are big hurdles, and it is not yet clear if all the many parties represented in parliament, including the opposition, are fully on board. But endorsement of the deal by Nahda, which holds 90 of the 217 seats in the interim constituent assembly elected in October 2011, raises hopes that two months of stalemate will end.

It all began with the murder, on July 25th, of Muhammad Brahmi, a left-wing member of the constituent assembly. Secular opponents of Nahda used this to heap pressure on the party, just as they had done after a strikingly similar assassination in February of another leftist politician. They said Nahda’s failure to take stronger actions against Islamist radicals had allowed extremism to spread unchecked. More than 50 assembly members temporarily withdrew in protest at Mr Brahmi’s death, including leftists, centrists in the Republican party and a handful of assembly members who had joined a rising new force, Nida Tounes (“Tunisian Call”), that has links to the pre-revolutionary regime of Zine el-Abidine Ben Ali.

Rallies demanding the government’s immediate resignation drew large crowds in August, along with calls for a mass-protest campaign to toss Nahda out of power, echoing what happened to the Islamists in Egypt. The movement tapped into frustration, expressed even by dismayed Nahda supporters, over its failure to redress economic and social ills. But momentum drained as most people showed little inclination to see at home horrific headlines like those coming out of Egypt.

A gruelling period of brinkmanship ensued. Nahda’s leaders were clearly loth to be bounced out by parties that had always found its 2011 election win unpalatable. Yet unlike Egypt’s Muslim Brothers, they shied away from full confrontation. Quietly changing tack, they stopped vilifying their most vociferous opponents as “counter-revolutionaries”. Only last year Nahda’s éminence grise, Rached Ghannouchi, dismissed Nida Tounes as a front for covering up the crimes and corruption of Mr Ben Ali’s dictatorship. But in recent weeks he has sought a rapprochement with its leader, Beji Caid Sebsi, a stalwart of the country’s first post-independence regime, who led an interim government after Mr Ben Ali’s fall.

Unlike Egypt, Tunisia’s modest-sized armed forces showed no inclination to intervene. Stronger than Egypt’s, Tunisia’s civil-society organs stepped into the breach instead. A group representing the powerful trade-union federation, the main employers’ union, the law association and human-rights groups shuttled between the jousting politicians. Faced with a prolonged paralysis in government for which it would have paid a big electoral price, Nahda backed down. Not only did it accede to the draft road map; it has signalled that it is prepared to give further ground over remaining articles in the constitution that its opponents regard as problematic, including one that refers to Islam as the religion of the state.

The Islamists are still trying to hedge their bets. In practice, they say, the Nahda-led government will cede power only once the constituent assembly has finalised a new constitution, and a new electoral commission is in place. Some of its opponents see this as infuriating sophistry or worse. Others are more understanding. Nahda needs to placate its most obdurate rank and file, whose dream of Islamising Tunisia chafes against the public’s longing for more tangible gains, but nevertheless allow the political process to go forward. It also wants a smooth transition rather than a disruptively abrupt one. Not for the first time, Egyptians are gazing at their distant neighbour with envy.