TUNISIA'S Islamist prime minister Ali Larayedh has resigned 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.

Troops in the city of Tatouine fired into the air and police used tear gas yesterday against protesters demonstrating over economic conditions.

Mr 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," Mr Larayedh said. "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 last year galvanised Ennahda's secular foes who demanded its members resign from power.