Ghannouchi is closely identified with former President Zine al-Abidine Ben Ali, who was toppled in an uprising last month. He served under Ben Ali's government since 1989.
The Prime Minister said he is resigning his post to avoid further violence and bloodshed in the country.
"After having taken more than one week of thinking, I became convinced, and my family shared my conviction, and decided to resign. It is not fleeing my responsibilities; I have been shouldering my responsibilities since 14 January [when Mr Ben Ali fled]," he said.
"I am not ready to be the person who takes decisions that would end up causing casualties," he added.
"This resignation will serve Tunisia, and the revolution and the future of Tunisia," he added.
Immediately after Ghannouchi's resignation, interim President Foued Mebazaa appointed as new Prime Minister, 84 years old Caid Essebsi, who has held several ministerial positions in the previous government of Habib Bourguiba who had led Tunisia to independence from France.
Caid Essebsi "is known for his patriotism, his faithfulness and his self-sacrifice for the benefit of the fatherland," said the president.
He thanked Ghannouchi for serving Tunisia in difficult times after hardline president Zine El Abidine Ben Ali fled the country to Saudi Arabia in mid-January after 23 years in power.
Paul Ross in his commentary, "the question now is whether this resignation will be enough to quell the violence. As the news has spread, people have been taking to the streets, chanting and singing of victory."