ISTANBUL — A Turkish court ordered the release of an American consular employee on Wednesday after almost two years in jail, while also convicting him of terror-related charges.

Hamza Ulucay, a translator who had worked at the United States Consulate in the southern city of Adana for over 30 years, was one of three employees of American consulates in Turkey detained over the past two years, along with several American citizens, in a growing confrontation between the two countries.

Mr. Ulucay was sentenced to four and a half years in jail for aiding an armed terrorist group, but he was ordered released with reductions for time served, the private Demiroren news agency reported.

The court, in the southeastern town of Mardin, ordered that he remain under travel restrictions that will prevent him from leaving the country, but he was able to return home on Wednesday.