ISTANBUL — North Carolina pastor Andrew Brunson was released from prison in Turkey Wednesday after being incarcerated for nearly two years there on terrorism charges.

Brunson is now under house arrest while the charges remain the same. He faces up to 35 years in prison, his lawyer told NBC News.

Brunson, 50, is an evangelical pastor from Black Mountain, North Carolina, who has spent the last 23 years living in Turkey, where he and his wife raised their daughter and two sons. He was running the Resurrection Church in the western city of Izmir when he was detained in October 2016 over accusations he helped individuals the Turkish government says were behind a failed coup.

“I talked to his family and they were very happy,” the pastor’s lawyer Ismail Cem Halavurt said, but added they felt “betrayed” after the court failed to release him earlier. “He will not be able to leave the house except if he has an interview or hearing in the court. He will be free at home but he can’t do anything else.”

Halavurt also said Brunson was in good physical condition, despite the Turkish state news agency reporting that he was released on health grounds.

Brunson's daughter Jacqueline Furnari told NBC News in April that he had started to gain back some of the 50 pounds he lost while in detention. "I'm not sure exactly why my dad was chosen," she said at the time. "He's a pawn in a political game between Turkey and the U.S."

Local television aired footage of what it said was Brunson being put into a white car and leaving prison Wednesday, surrounded by several other vehicles, led by a police car and motorbikes. U.S. Secretary of State Mike Pompeo tweeted afterwards that the U.S. welcomed the news.

We welcome long overdue news that Pastor Brunson has been moved from prison to house arrest in #Turkey, but it is not enough. We have seen no credible evidence against Mr. Brunson, and call on Turkish authorities to resolve his case immediately in a transparent and fair manner. pic.twitter.com/So2A4hfinZ — Secretary Pompeo (@SecPompeo) July 25, 2018

He tweeted, “but it is not enough. We have seen no credible evidence against Mr. Brunson, and call on Turkish authorities to resolve his case immediately in a transparent and fair manner.”Halavurt said he filed a petition for house arrest after the court failed to release Brunson during a court hearing on July 18. Under the terms of house arrest granted Wednesday, Halavurt said that authorities will likely keep Brunson’s passport and make him wear an electronic ankle bracelet.

The Turkish state news agency said the court banned Brunson from leaving the country.

There was heightened hope for Brunson’s release after President Donald Trump met with Turkish President Recep Tayyip Erdogan at a NATO summit this month. Trump has repeatedly called for Brunson’s release, stating last week’s decision not to release him was “a total disgrace.” “He has been held hostage far too long,” Trump tweeted last week. “[Erdogan] should do something to free this wonderful Christian husband & father.”

A total disgrace that Turkey will not release a respected U.S. Pastor, Andrew Brunson, from prison. He has been held hostage far too long. @RT_Erdogan should do something to free this wonderful Christian husband & father. He has done nothing wrong, and his family needs him! — Donald J. Trump (@realDonaldTrump) July 19, 2018

U.S. Sens. Lindsey Graham and Jeanne Shaheen met with Erdogan in June, adding to hopes that Brunson would be released. Shaheen said in statement afterwards that she met with the pastor in prison and asked Turkey’s president to release him.

Erdogan had previously implied that Brunson’s release would be conditional on the U.S. extraditing Turkish cleric Fethullah Gulen, who lives in self-imposed exile in Pennsylvania. The Turkish government has accused Gulen of masterminding an attempt to overthrow the government in July 2016, a charge he denies.

Opponents of Erdogan claim he has used the coup to crackdown on dissent. About 160,000 people have been detained following the failed attempt, the U.N. Human Rights Office said in March, and a U.S. official told NBC there is a “small handful” of U.S. citizens in detention following the overthrow effort.

Brunson’s case created another point of tension in Washington’s relationship with Turkey. U.S. senators passed a bill in May prohibiting Turkey from buying F-35 fighter jets partly due to Brunson’s imprisonment.

Turkey is a crucial NATO ally, bordering Iraq and Syria, and the country hosts a U.S. airbase where strikes against ISIS have been launched. The relationship between the U.S. and Turkey has been strained, partly due to American support for Kurdish fighters in Syria. The Turkish government says those fighters are connected to a Kurdish militant group in Turkey that is considered a terrorist organization by both countries.

On July 16, two days before Brunson’s court hearing, Trump and Erdogan held a phone call to discuss implementing a plan to withdraw Kurdish fighters from an area of Syria, according to the Turkish government. It added the two had said they were committed to improving ties.