Tunisia's Islamist Prime Minister Ali Larayedh resigned today to make way for a caretaker government in an agreement with secular opponents to complete the country's transition to democracy.

Three years after its uprising against Zine el-Abidine Ben Ali, Tunisia is in the final stages of establishing a full democracy before new elections.

Tunisia's new premier, technocrat Mehdi Jomaa, must tackle subsidy cuts sought by international lenders to curb the small North African country's deficit and also confront a growing threat from Islamist militants.

Illustrating the continued fragility, troops in the southern city of Tatouine fired into the air and police used tear gas today to disperse protests over economic hardship.             

To end months of political crisis, Mr Larayedh's moderate Islamist party Ennahda agreed late last year to a deal to handover to an independent cabinet led by Mr Jomaa, who will govern until the election.

"I have just handed my resignation to the president," Mr Larayedh told reporters.

"The president will appoint the new prime minister, Mehdi Jomaa, shortly and he will present his new cabinet in the next few days."

One of the most secular countries in the Arab world, Tunisia has struggled with divisions over the role of Islam and the rise of Islamist radicals since the uprising in 2011 that inspired other revolts in the region.        

Tunisia's largely peaceful transition has been widely watched as a model for other nations struggling with instability since their own "Arab Spring" revolts.

But the killings of two secular Tunisian opposition leaders by gunmen last year galvanised Ennahda's secular foes, who took to the streets to demand the government resign, accusing it of being too lax with hardliners.

After months of wrangling, Ennahda reached a compromise with the main opposition Nidaa Tounes and its allies to resign once parties had finished a new constitution, set a date for fresh elections and appointed a body to oversee the vote.

Much of that agreement has now been implemented.

Th enational assembly is voting on the last clauses of the new charter this week and last night the assembly appointed a nine-member electoral commission.