* New caretaker cabinet will govern until elections
* Agreement will see Islamist party resign from power
* Economy, militant violence, pressuring parties to accord
Tunisia's ruling Islamists and opposition parties agreed on Saturday to name the country's current industry minister as prime minister of a caretaker technocrat cabinet to govern until elections next year.
The appointment is the first step in an agreement that will see moderate Islamist party Ennahda hand over power in the next few weeks to end a crisis that threatened Tunisia's transition to democracy after its 2011 uprising.
Three years after its protests against autocrat Zine el-Abidine Ben Ali inspired Arab uprisings elsewhere, Tunisia has been struggling to overcome disputes over the role of Islam in one of the Arab world's most secular countries.
After weeks of wrangling, parties agreed to name Mehdi Jomaa, an aerospace engineer by training, as premier in a deal between Islamist party Ennahda and a coalition of secular parties led by a former Ben Ali official.
"Despite the difficulties, we have managed to reach an agreement over the name of Mehdi Jomaa," Hussein Abassi, head of the UGTT union movement that brokered the talks, told reporters. "The next government should be independent and nonpartisan to led the country to elections."
Ennahda won the most seats in a national assembly selected in the first elections after the fall of Ben Ali, but the country struggled with a widening gap between Islamists and secular leaders.
Months of protests erupted after the assassination of two opposition leaders this year by Islamist militant gunmen, and secular opposition parties formed a broad coalition demanding Ennahda's resignation.
Under a union-brokered agreement, Ennahda accepted that the coalition government would step down once politicians decided on a caretaker cabinet, completed a new constitution and set a date for elections.
Tunisia's crisis has hurt its economy and prospects of generating prosperity in the nation where a street vendor set himself on fire nearly three years ago in a gesture of despair that ignited a flame of revolt across the Arab world.
The first suicide bombing in a decade earlier this year highlighted the growing threat from militant Islamists who have been able to use the chaos in neighbouring Libya to gain arms and training.
However, Tunisia has fared better than both Libya and another North African neighbour, Egypt, that also toppled their leaders. Egypt's elected Islamist president is in jail after the military ousted him, and Libya is struggling to control militias that fought Muammar Gaddafi.