Unlike many Western governments, NATO-member Turkey had kept its embassy open since an uprising against Gaddafi's rule began in February. It had been looking after the interests of the United States, Britain and Italy.
"We decided to evacuate our embassy in Tripoli temporarily due to security reasons," Foreign Minister Ahmet Davutoglu told reporters. "Our ambassador to Tripoli has traveled safely to Tunisia in the morning. Turkey is closely monitoring the changing security conditions in Libya."
Demonstrators targeted both the British and Italian embassies after an airstrike Saturday killed a son of Gaddafi and three grandchildren.
A dozen international staff working for the United Nations also left Libya after a crowd of people entered a U.N. compound and took vehicles.
Muslim Turkey had sizable trade and commercial ties with Gaddafi's Libya, and evacuated more than 20,000 citizens working there as violence engulfed the North African country.