An American pastor has flown out of Turkey after he was released by a Turkish court following two years in detention.

Andrew Brunson, whose detention caused a diplomatic crisis between Washington and Ankara, left on a US military flight bound for Germany on Friday. The White House said Brunson will arrive at a military base in Maryland on Saturday.

The evangelical pastor was convicted of terror-related charges and sentenced to three years, one month and 15 days in jail on Friday.

{articleGUID}

But he was immediately freed, taking into account the time already served and good conduct during the trial. The court also lifted his house arrest and overseas travel ban, paving the way for his return to the US.

After the court decision, Brunson travelled to his home and then left for the airport in Izmir province with his wife Norrine.

“This is the day our family has been praying for – I am delighted to be on my way home to the United States,” Brunson said in a statement after his release.

Andrew Brunson, US pastor who has been in house arrest in Turkey, is sentenced to three years, one month and 15 days in prison. Judicial control and travel ban are lifted. Brunson is expected to be released and leave Turkey later today. @AJEnglish pic.twitter.com/8C1yfj6C4D — Umut Uras (@Um_Uras) October 12, 2018

“This is good news for the Americans, as well as the Turkish market. Everybody was waiting for this court decision, as there was pressure on the Turkish lira following the tension between the US and Turkey” over the Brunson case, reported Al Jazeera’s Sinem Koseoglu from Izmir, after the court reached its decision.

After the court ordered Brunson’s release, US President Donald Trump tweeted that his “thoughts and prayers” were with the pastor, adding that he “will be home soon” in another Tweet.

Brunson, 50, was arrested in 2016 as part of the government crackdown in the wake of a failed coup bid. He has been under house arrest since July.

Friday’s court decision ends the friction over his case that caused a crisis in relations between the two NATO allies.

With Washington slapping sanctions on Ankara, the crisis also sparked a crash in the Turkish lira in August that exposed Turkey’s economic fragility.

Galip Dalay, a visiting scholar at the University of Oxford, said that the release of Brunson removes a main source of tension in the relations between Washington and Ankara.

“The judgement opens the way for the two countries to cooperate further in and focus on the other areas of mutual interest such as the Syrian crisis and the case of Jamal Khashoggi,” he said, referring to the Saudi writer and critic who disappeared earlier this month after entering the Saudi consulate in Istanbul.

“The US sanctions on Turkey are likely to be removed after this development, as well.”

The US evangelical preacher was accused of links with Kurdish rebels and supporters of Fethullah Gulen, whom Turkey blamed for the failed coup attempt. Gulen has denied any involvement.

Brunson, who has lived in Turkey for more than 20 years, has denied the charges and maintained his innocence.

The US had maintained he was held unjustly and repeatedly called for his release.

Following the court ruling, an official for the Turkish presidency said the verdict showed the independence of the judiciary in the country.

“It is with great regret that we have been monitoring US efforts to mount pressure on Turkey’s independent court system for some time,” Fahrettin Altun, the presidency’s communications director, said.

“Like the Turkish courts, the Republic of Turkey does not receive instructions from any body, authority, office or person. We make our own rules and make our own decisions that reflect our will,” Altun said in a statement.

Turkish President Recep Tayyip Erdogan has insisted that he had no sway over the judiciary and that the courts would decide on Brunson’s fate.

Additional reporting by Umut Uras (@Um_Uras) from Istanbul.