MONTREAT – A dozen or so members of Christ Community Church here have met regularly at 2 a.m. -- 9 a.m. in Turkey -- on the days pastor Andrew Brunson's trial was in session in Turkey to pray for him.

But on Friday, the talk was of planning a celebration of the release of the missionary from Black Mountain, not the next prayer vigil at Brunson's home church.

Early Friday, a Turkish court convicted Brunson of espionage charges but handed down a sentence that meant he was freed immediately for time served, ending a two-year ordeal.

Church members and staff were "doing the happy dance and shouting, 'Hallelujah!' " spokeswoman Debi Forester said.

Brunson is expected to return to the United States in a few days, but reportedly was to be flown first to Germany for medical evaluation.

That will ease a diplomatic standoff between the U.S. and Turkey and end suffering by Brunson and his family that began when he was first taken into custody on unspecified charges in Turkey in October. 2016.

He had been held behind bars until being transferred to house arrest in July.

Brunson had led a small Christian congregation in Izmir in western Turkey before his detention and has spent more than 20 years working in the country.

The court sentenced Brunson to three years and one month in prison for the conviction, but since the evangelical pastor has already spent two years in detention he won't serve more time under Turkish law.

Christ Community Church members had prayed for Brunson and worked to raise awareness of his case. Some members had visited him and his wife, Norine, in Turkey a couple of years before he was detained.

Brunson, 50, had been behind bars from 2016 until July, when he was moved to house arrest in Izmir. He had strongly maintained his innocence on the terrorism and espionage charges against him throughout and his supporters called some of the accusations against him absurd.

“My entire family thanks the President, the Administration, and Congress for their unwavering support," he said in a statement released by the American Center for Law and Justice, a nonprofit that had coordinated his defense.

"This is the day our family has been praying for – I am delighted to be on my way home to the United States. It’s been an extremely difficult time for our family and we want to express our appreciation to the millions of people around the world who have faithfully prayed for this day," Brunson said.

Diplomatic, economic pressure on Turkey key in securing Brunson's release

The Trump administration called for Brunson's release and imposed economic sanctions against Turkey. Congress passed legislation delaying the planned sale of fighter jets to Turkey in part due to Brunson's incarceration.

"It's a great day," U.S. Sen. Thom Tillis, a North Carolina Republican who was a leader in those efforts, said in a telephone interview Friday.

Tillis had visited Brunson twice in Turkey and said he spoke with the pastor Sunday on the second anniversary of his detention.

"We were talking about the best possible outcomes and this was it, being able to get him out of the country," Tillis said.

He attributed Friday's outcome to diplomatic and economic pressure from the White House and Congress and work by Brunson's supporters to keep his case in the public eye.

"I think it's that very visible and persistent focus on it that led us to this point," he said.

Tillis spoke regularly on the Senate floor calling for Brunson's release.

Brunson headed back to U.S., Sen. Thom Tillis and President Donald Trump react

On Friday, the pastor told the court he is "an innocent man. I love Jesus, I love Turkey."

Media outlets including The New York Times and The Washington Post reported that witnesses in the trial Friday contradicted previous testimony against Brunson.

The court called two witnesses following tips from witness Levent Kalkan, who at the previous hearing had accused Brunson of aiding terror groups, The Associated Press reported. The new witnesses did not confirm Kalkan's accusations. Another witness for the prosecution said she did not know Brunson.

Brunson again denied accusations that his church aided Kurdish militants, saying he had handed over a list of Syrian refugees whom the congregation had helped and adding that Turkish authorities would have identified any terrorists.

"We helped everyone, Kurds, Arabs, without showing any discrimination," he said.

There had been reports Thursday that Brunson would be released via a deal between the U.S. and Turkey that would involve easing or ending U.S. sanctions.

President Donald Trump and his administration have said charges against Brunson are false and have demanded his release. The the case has added further complications to an already strained relationship.

"I'm very hopeful that before too long Pastor Brunson ... and his wife will be able to return to the United States," Secretary of State Mike Pompeo said Wednesday. "It's the right thing for (Turkey) to do, it's the humanitarian thing for Turkey to do."

Turkey's economy has swooned in recent months, partly because of the U.S. sanctions, and analysts said friction between the U.S. and Turkey over Brunson's captivity has bee a major cloud over investors' decisions regarding Turkey.

The value of the Turkish currency, the lira, has fallen 40 percent this year and inflation stands at a 25 percent annual rate.

More:Reports: Pastor Andrew Brunson's release could be imminent

More:Jailed missionary with local ties living 'dark days' in Turkey

More:Charges against Brunson contain a strange mix of conspiracy theories — and a food video

Brunson case linked to cleric's

Brunson was is one of thousands of people who were jailed in Turkey on what many international observers say are dubious charges following a failed coup attempt.

Turkish President Recep Tayyip Erdogan has in the past publicly linked Brunson's fate with that of Fetullah Gulen, a Turkish cleric in exile in Pennsylvania. Turkey says Gulen was an instigator of the coup, a charge Gulen denies.

Turkey asked the U.S. to extradite Gulen, but the U.S. says Turkey has not provided evidence to back up the accusation and has allowed Gulen to stay in the U.S.

More recently, Erdogan said he would not put any political pressure on judges hearing Brunson's case, citing judicial independence.

“I’ll have to abide by whichever decision the judiciary makes,” the Turkish newspaper Hurriyet quoted him as saying, according to Reuters news service. “Those who are subject to it also must obey the judiciary decision.”

Those remarks were seen as a way for Erdogan's to back away from a previous hard line he had taken on Brunson's fate.

Implications in U.S., Turkey

While Brunson's case has gotten attention in the U.S., particularly among evangelical Christians, it was even more widely publicized in Turkey.

Letting him go might create some domestic fallout for Erdogan. However, Erdogan's hold on the levers of power in Turkey appears so strong that public opinion of the Brunson case may not be a big worry for him -- and, continuing problems with the Turkish economy could pose more of a threat to him than a reversal in the Brunson case.

Turkey is also seeking U.S. support in its dispute with Saudi Arabia over the fate of Jamal Khashoggi, a Saudi journalist in exile that Turkey says was murdered inside a Saudi consulate in Turkey.

Brunson was far from the only cause of strained relations between Turkey and the U.S. Another detainee in Turkey is NASA scientist Serkan Golge, who holds dual U.S. and Turkish citizenship. He has also maintained his innocence and many international observers doubt charges against him.

The two countries have also differed over how to handle the civil war in Syria and Turkey's interest in buying arms from Russia.

The Associated Press contributed to this report.