US pastor held for 2 years freed by Turkish court Pastor Andrew Brunson's case had created a deep rift in U.S.-Turkish relations

A Turkish court has freed American pastor Andrew Brunson after two years in detention, according to Turkish state media.

His case had created a deep rift in U.S.-Turkish relations, with the Trump administration heavily committed to securing his freedom and punishing its NATO ally with economic penalties for not doing so. An evangelical Christian pastor, he had also become a rallying cry for religious freedom advocates in the U.S.

President Donald Trump tweeted about his impending release Friday, saying his administration was "working very hard" on his case and adding later, "PASTOR BRUNSON JUST RELEASED. WILL BE HOME SOON!"

Brunson, who was detained in a Turkish prison until he was moved to house arrest in July, was convicted of terrorism and espionage charges, which his lawyers have denied as baseless. The court in Izmir, Turkey, sentenced him Friday to three years and one a half months, but given his time served and that it was his first arrest, his house arrest and travel ban have been lifted.

That means he could leave the country, where he worked as a pastor for two decades, as soon as Friday.

Brunson was detained in October 2016 and formally arrested that December. He was charged with ties to two groups Turkey considers terrorist organizations: A Kurdish separatist group called the PKK that the U.S. has also designated a terrorist organization, and the Gulenists, a political-religious movement led by exiled cleric Fetullah Gulen who Turkish President Recep Tayyip Erdogan has accused of fomenting a 2016 failed coup attempt.

Gulen, who is a lawful permanent resident of the U.S. living in Pennsylvania, has denied that allegation.

Brunson's lawyer Ismail Halavurt told ABC News they would still move to appeal his case because they reject all the charges.

The Trump administration had sanctioned two senior Turkish officials over Brunson's longtime detention -- Justice Minister Abdulhamit Gül and Interior Minister Süleyman Soylu -- calling them "leaders of Turkish government organizations responsible for implementing Turkey’s serious human rights abuses," according to the Treasury Department.

Shortly afterward, the U.S. also imposed steel and aluminum tariffs on Turkey, citing national security. The economic penalties sparked trouble in the markets, leading to Turkey's currency to plunge.

It was unclear Friday if the U.S. would now lift those sanctions, as the two NATO allies seek to repair ties.

"Brunson's release is a big deal for U.S.-Turkey relationship: It clears the air in [bilateral] ties, resets ties between two powerful presidents, lets off steam against Turkey in U.S. Congress, and allows Turkey and the U.S. to tackle [bilateral] issues without the emotional dimension of the pastor's arrest," according to Soner Cagaptay, director of the Turkish Program at the Washington Institute for Near East Policy.

Among those thorny issues that remain are Turkey's purchase of a Russian missile system, U.S. support for Kurdish groups in Syria, and Erdogan's sweeping crackdown on political opposition.

ABC News's Ben Gittleson contributed to this report.