SINCE its revolution in 2011, battalions of experts have advised Tunisia on everything from building consensus to drafting election rules. The country that sparked the Arab spring seemed to show the rest of the region what a functioning democracy might look like. But the coup in neighbouring Egypt and this year’s second political assassination of a Tunisian opposition politician have sent it off course.

The ousting of Muhammad Morsi, Egypt’s elected Islamist president, on July 3rd, inspired some young Tunisians, unhappy with their own Islamist-led government, to form a copycat movement aimed at toppling it. The assassination on July 25th of Muhammad Brahmi, head of the leftist People’s Party, further encouraged them. Two men on a motorbike drew up outside his house in a suburb of the capital, Tunis, and fired 14 bullets at him.

There was no mistaking the similarity with the killing on February 6th of Chokri Belaid, the leader of another leftist opposition group, the Unified Democratic Nationalist party. Both men were outspoken critics of political Islam.

The interior minister, Lotfi Ben Jeddou, says that the same gun is believed to have been used in both shootings. The police are apparently tracking eight suspects. They may have links to al-Qaeda in the Islamic Maghreb (AQIM), an extremist group active across north-west Africa.

Tunisians have been asking why the police, if they already had a list of suspects, could not pre-empt the second killing. The opposition Nida Tounes party, headed by veteran politician, Beji Caid Sebsi, joined the main trade union, the UGTT, in accusing the ruling Islamist Nahda party of having been too tolerant of violent extremists. Nahda’s argument that the transition to democracy is always rocky sounds increasingly hollow.

Within days, 60 opposition members of the 217-strong constituent assembly, elected in October 2011, resigned and called for the establishment of a new government headed by a non-party figure. Thousands of anti-government protesters gathered outside the assembly building in Tunis; riot police separated them from Nahda supporters. Despite Mr Ben Jeddou’s assurance that there would be no clampdown on peaceful protests, the police used tear gas and batons.

Unlike in Egypt, few protesters would welcome an army-sponsored government. Party leaders are under pressure to negotiate a deal to keep the political process on track. Alluding to potential coup plotters, the prime minister, Ali Laarayedh, declared that only those who had been elected could claim to speak for the Tunisian people. He refused to step down, reiterating that a general election would be held in December. In inter-party talks this week, he seemed ready to accept a broader national unity government, but not to dissolve the assembly.

Meanwhile, as if to highlight tensions further, eight soldiers were killed in the mountainous Jebel Chambi area which borders Algeria and is a haven for militants. The politicians will need to use their consensus-building skills.