Under the agreement signed after talks in Tunis on Saturday, a cabinet of independent figures will be in power until fresh elections.
The two sides also agreed to hold further negotiations on the formation of the new technocratic cabinet within three or four weeks.
The caretaker government is to supervise new elections.
Last month Ennahda agreed to step down in a bid to end Tunisia's political stalemate.
Tunisia has been in crisis for weeks after the killing of Mohamed Brahmi, the leader of the left-wing Popular Movement party, on July 25. The opposition lashed the government for failing to maintain security and tolerating the militants it accused of being behind the killing.
Negotiations are still delicate, but Ennahda has agreed it will step down at the end of three weeks of talks to decide on the composition of the caretaker administration and set a date for new elections.
"It's a fragile balance now, we have to work to find a consensus," said Maya Jibri, a leader of a secular opposition party at talks in the Palais de Congres hall in central Tunis.
Since autocrat Zine al-Abidine Ben Ali was ousted in 2011 after street protests against his rule, Tunisia has been struggling with political crisis.
RA/HH