A Turkish court has convicted an American pastor at the center of a Turkish-American diplomatic dispute of terror charges, but has released him from house arrest and allowed him to leave Turkey.

The court near the western city of Izmir on Friday sentenced Andrew Brunson to 3 years and 1 month in prison for the conviction, but since the evangelical pastor has already spent two years in detention he won't serve more time.

Brunson, 50, had rejected the espionage and terror-related charges and strongly maintained his innocence.

Lawyer Ismail Cem Halavurt said Brunson was expected to leave Turkey for the United States

State Department spokeswoman Heather Nauert told reporters on Thursday that the U.S. was hopeful he would soon go free but said she was unaware of any agreement on his release.

The pastor, who is originally from Black Mountain, North Carolina, was imprisoned for nearly two years -- detained in October 2016 and formally arrested in December that year -- before being placed under house arrest on July 25 for health reasons.  

(The Associated Press, CBS News contributed to this report.)