ANKARA:- A Turkish courtinfo-icon has ordered the release of an American evangelical Christian pastor whose imprisonment sparked a row between Ankara and Washington.

The court on Friday sentenced Andrew Brunson to three years and 1-1/2 months in jail on terrorism charges, but released him after taking into account time served and good conduct.

The pastor was detained two years ago and has been under house arrest in the city of Izmir since July.

Brunson, 50, was indicted by a Turkish court on charges of having links with the Kurdistan Workers' Party (PKK) militant group and the movement of the USinfo-icon-based opposition cleric Fethullah Gulen, whom Ankara accuses of having masterminded the July 2016 coup attempt against President Recep Tayyip Erdogan. Brunson has already denied the charges.

His detention sparked a widening rift between Turkeyinfo-icon and the US. Washington called for Brunson's release and taken a series of punitive measures against Turkey over the continued detainment of the evangelical Christian pastor.

The US measures, which include imposing sanctions on Turkish ministers and doubling of steel and aluminum tariffs, have led to a sharp decline in the Turkish currency. Turkey has retaliated by raising tariffs on certain US imports.

After the ruling, Brunson's lawyer said the pastor was likely to leave Turkey.

Trump: Brunson 'will be home soon'

My thoughts and prayers are with Pastor Brunson, and we hope to have him safely back home soon!

US President Donald Trumpinfo-icon has threatened to slap "large sanctions" on Turkey if it fails to free detained American Christian pastor Andrew Brunson.

Brunson said in a statement on Friday that he was heading home soon.

"This is the day our family has been praying for -- I am delighted to be on my way home to the United Statesinfo-icon."

He also voiced gratitude to Donald Trump, saying "My entire family thanks the president, the administration, and Congress for their unwavering support."

American officials were quoted as saying that the US military has a plan to fly the pastor back to Americainfo-icon on a military aircraft.

US broadcaster NBC said on Thursday that Turkey and the US had reached a secret deal to secure Brunson's release.

But Turkey said its judiciary is independent and US State Department spokeswoman Heather Nauert said she was "not aware" of any such settlement.

Turkey and the US also disagree over their military interventions in the Syriainfo-icon warinfo-icon, Ankara's plan to buy missileinfo-icon defense systems from Russiainfo-icon and the US conviction of a Turkish state bank executive on sanctions-busting charges in January.