IZMIR, Turkey (Reuters) - A U.S. pastor was flown out of Turkey on Friday after a court freed him from two years of detention, in a step that could improve U.S.-Turkish ties strained by disputes over Syria, Iran and Ankara’s planned purchase of Russian military equipment.

Pastor Andrew Brunson was expected to land at Joint Base Andrews near Washington at around noon EDT (1600 GMT) on Saturday after a stop in Germany for a medical check-up.

Brunson was jailed two years ago and had been under house arrest since July. He was accused of links to Kurdish militants and supporters of Fethullah Gulen, the cleric blamed by Turkey’s government for a coup attempt in 2016.

The Turkish court sentenced Brunson to three years and 1-1/2 months in prison on terrorism charges, but said he would not serve any further jail time and freed him.

Brunson, who has lived in Turkey for more than 20 years, denied the accusations and Washington had demanded his immediate release.

U.S. Ambassador Richard Grenell greeted Brunson and his wife during a refueling stop in Germany, the envoy said on social network Twitter.

“He’s almost home thanks to @realDonaldTrump,” Grenell wrote. “When I presented him with the US flag, he immediately kissed it.”

President Donald Trump said Brunson would probably visit the White House Oval Office on Saturday.

Asked if U.S. sanctions imposed on Turkey to try to win Brunson’s release might be lifted, Trump said no agreement was made for the pastor’s freedom.

Slideshow ( 16 images )

“There was no deal made at all. There was no deal. But we’re very happy to have him and have him in good shape.” Trump told reporters in Cincinnati.

The diplomatic fight over Brunson had accelerated a recent sell-off in Turkey’s currency, worsening its financial crisis.

‘GREAT CHRISTIAN’

Dressed in a black suit, white shirt and red tie, Brunson wept as the court decision was announced, witnesses said. Before the judge’s ruling, he had told the court: “I am an innocent man. I love Jesus. I love Turkey.”

Witnesses told the court in the western town of Aliaga that testimony against the pastor attributed to them was inaccurate.

Brunson’s mother told Reuters she and his father were elated at the news. “We are overjoyed that God has answered the prayers of so many people around the world,” she said by telephone from her home in Black Mountain, North Carolina.

Trump has used the Brunson case to try to score points with evangelical Christians, a large part of his political base, ahead of the Nov. 6 congressional elections, which will determine whether Republicans keep control of Congress.

He has called Brunson, a native of North Carolina, a “great Christian”, and Vice President Mike Pence, the White House’s top emissary to evangelicals, had urged Americans to pray for Brunson.

Slideshow ( 16 images )

“We thank God for answered prayers and commend the efforts of @SecPompeo & @StateDept in supporting Pastor Brunson and his family during this difficult time,” Pence said on Twitter. “@SecondLady and I look forward to welcoming Pastor Brunson and his courageous wife Norine back to the USA!”

U.S. broadcaster NBC said on Thursday that Washington had done a secret deal with Ankara to secure Brunson’s release.

Senator Thom Tillis, a Republican from North Carolina, told Reuters that active engagement by Trump and U.S. Secretary of State Mike Pompeo contributed to Brunson’s release.

“A lot of factors played into this,” Tillis said, adding the United States was trying to “get back to a point of a positive relationship” with Turkey.

NATO ALLIES

Relations between the two NATO allies have been under serious strain over U.S. support for Kurdish fighters in northern Syria, Turkey’s plans to buy a Russian missile defense system, and the U.S. jailing of an executive at a Turkish state bank in an Iran sanctions-busting case.

The release of Brunson could help ease tensions, but political analysts say many unresolved problems remain.

“This is a necessary but far from sufficient step to reverse what has been a deepening rift between the United States and Turkey, two NATO allies,” said Jon Alterman, director of the Middle East program at the Center for Strategic and International Studies in Washington.

Attention may now turn to the fate of a Turkish-U.S. national and former NASA scientist in jail in Turkey on terrorism charges, as well as three local employees of the U.S. consulate who have also been detained.

Washington wants all of them released.

“We hope that the Turkish government will quickly release our other detained U.S. citizens and @StateDept locally employed staff,” Pompeo said on Twitter.

Ankara has demanded that the United States extradite Gulen to Turkey. The cleric, who was lived in self-imposed exile in the United States since 1999, denies any role in the attempted coup.