American pastor Andrew Brunson, who has been imprisoned in Turkey for nearly two years on dubious charges of terrorism and espionage, was convicted of terror charges Friday but released from house arrest on time served, The New York Times reports. The judge reduced Brunson’s sentence from five years to three years, one month, and 15 days, the Financial Times reports, and lifted all judicial controls to allow to him to fly home to the U.S., citing time served and good behavior. Brunson, an evangelical pastor who runs a church in Izmir, was first detained alongside about two dozen other Americans during a failed coup attempt in 2016. He denies all the charges against him. Brunson has been entangled for months in a diplomatic crisis between President Trump and Turkish President Tayyip Erdoğan. He was supposed to have been released in July in a trade-off, but the deal fell through and talks soured soon after.