By Patrick Markey and Aziz El Yaakoubi
TUNIS (Reuters) - Tunisia's Islamist Prime Minister Ali Larayedh resigned on Thursday to make way for a non-partisan caretaker government as part of a deal with his opponents to complete a transition to democracy.
Three years after an uprising against autocrat Zine el-Abidine Ben Ali, Tunisia is in the final stages of establishing a full democracy before elections that would be a rare bright spot in an unstable region.
Illustrating the country's continued fragility, troops in the city of Tatouine fired into the air and police used tear gas earlier on Thursday against protesters demonstrating over economic conditions, the state news agency said.
Larayedh's moderate Islamist party Ennahda agreed late last year to the deal which called for its government to hand over to a non-partisan cabinet led by Mehdi Jomaa, a technocrat who will govern until the elections.
"I have just handed my resignation to the president," 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 militants since the uprising in 2011 that inspired other revolts in the region.
Tunisia's transition has been mostly peaceful since 2011. But the killings of two secular opposition leaders by gunmen last year galvanized Ennahda's secular foes who took to the streets to demand its members resign from power, accusing them of being too lax with hardliners.
After weeks of wrangling, Ennahda reached a compromise with main opposition Nidaa Tounes to resign once parties had finished writing the new constitution, set a date for elections and appointed an electoral council to oversee the vote.
Much of that agreement has been done: The national assembly is voting on the last clauses of the new charter this week and on Wednesday night the assembly appointed a nine-member electoral commission.
But Tunisia's new government will have to tackle economic reforms to cut back its deficit while managing simmering popular discontent over the high living costs and lack of economic opportunities since the revolution.
After two days of protests in several cities over an increase on vehicle taxes, Larayedh said earlier on Thursday the government would suspend the tax reform.
The state news agency said troops opened fire into the air and police used tear gas to repel hundreds of protesters in Tatouine, where they attacked two police stations and an Ennahda party office.
No injuries were reported and local residents said the army had brought the situation under control later the same day.
International lenders such as the World Bank and the International Monetary Fund are keen for Tunisia to cut back on public subsidies to control its budget deficit. But public spending cuts risk sparking anger among the population.
Authorities say Islamist militants from the Ansar al-Sharia group, whose leader pays allegiance to al Qaeda, are also a growing threat for the small North African country whose economy relies heavily on foreign tourism.
A suicide bomber blew himself up at popular beach resort late last year - Tunisia's first such attack in a decade.
Islamist parties who rose to political power after the 2011 revolts in Egypt and Libya have fared less well than Ennahda, whose compromise with secular opponents will allow them to again take part in elections this year.
Egypt's democratically elected President Mohamed Morsi faces trial after the military ousted him, and Libya's Muslim Brotherhood-allied party is locked in political crisis with secular foes in their parliament.
(Reporting by Patrick Markey and Aziz El Yaakoubi; editing by Raissa Kasolowsky)