Col. Mohammed Hegazy told reporters in Benghazi that citizens of the two countries have 48 hours to leave, warning that unspecified measures will be taken against those who are found after the ultimatum, which he said started Saturday.
"Citizens carrying Turkish or Qatari nationalities must leave the area between Imsaid crossing (by the Egyptian border) and the city of Sirte (in central Libya) within 48 hours," he said.
Hegazy said the public is angered from the policies of Turkey and Qatar and accused the two countries of sending spies to eastern Libya. There was no immediate comment from either country.
Hegazy is the spokesman for Gen. Khalifa Hifter, who launched an offensive against Islamists, accusing them of terrorism. Hifter also accused Qatar of supporting the militants.
Both countries are supporters of the Muslim Brotherhood, a leading Islamist force in Libya and elsewhere in the region.
Turkey had closed its consulate in Benghazi earlier this month, and warned its citizens against traveling there because of the deteriorating security condition.
Libya has been roiled by lawlessness and mushrooming militias who have been operating in beside government agencies since the fall and death of longtime dictator Moammar Gaddafi.
Benghazi has particularly been hit by violence, with assassinations and revenge attacks by Islamist militias and other groups claiming the lives of senior officials as well as diplomats.
