Tunisia’s late president Beji Caid Essebsi was unable, or unwilling, to rein in a security apparatus that reared its head after the 2011 revolution and sought to groom his son as his successor, raising fears that the country was sliding back into dictatorship.
But Caid Essebsi, who died on Thursday of natural causes, differed markedly from leaders of nominal Middle East republics in that he was ready to face his religious rivals' challenge at the ballot box rather than exclude them.
His party, Nidaa Tounes, won 37.6 per cent of the votes in the country’s last parliamentary election in 2014, compared with 27.8 per cent for the moderate Ennahda party.
Its share of the vote had fallen from 37 per cent in 2011, when Tunis held its first open elections after the uprising.
Nidaa Tounes formed a coalition government including Ennahda, defying the Arab secularist idea that republican strongmen should remain in power even when they are ruining their countries, because democratic reform would lead to permanent rule by religious parties.
Those parties mostly did not contest the accompanying presidential elections 2014, which Caid Essebsi won.
He then sought to install his son Hafedh as Nidaa Tounes leader, sowing division among its ranks.
Reports at the time suggested that Ennahda was wary that after the 2013 toppling of Muslim Brotherhood president Mohammed Morsi in Egypt, a similar scenario would befall Tunisia if a non-secular president were elected.
But Ennahda may have also calculated that Caid Essebsi was unstoppable.
His electoral success was due to a complex set of political and societal factors, including the emergence of Salafists and Al Qaeda-linked militants in Tunis .
This made many women fear for their place in society.
Then there was support from the security apparatus and Ennahda’s willingness to abide by democracy and remain committed to non-violence.
In an interview with the pan-Arab daily Al Hayat shortly after he set up Nidaa Tounes in 2014, Caid Essebsi said his non-secular rivals had "Stalinist discipline" but that their support base was relatively small, despite riding the coattails of the Tunisian revolution.
He said the revolution “did not erupt for the sake of Sharia or for the sake of clerical rule, but for the sake of dignity”.