American pastor Andrew Brunson, who was swept up in a wave of arrests in the wake of a failed coup attempt in Turkey, was released on Friday, easing a major controversy between the United States and the NATO ally.

A judge ordered Brunson's release as part of a reported deal in which President Trump will “ease economic pressure” on President Recep Tayyip Erdogan’s country. Turkey is not dropping the case against Brunson. The prosecutor “demanded up to 10 years in prison for terror charges,” a pro-government outlet reported, but Brunson will be allowed to leave the country.

“The Second High Criminal Court in western Izmir province on Friday ruled for American pastor Andrew Craig Brunson to be sentenced to three years, one month and 15 days in prison, but said he will not spend anymore time in custody because of the time he has already served,” Daily Sabah reported.

Trump tweeted in support of Brunson's release Friday morning.

The Trump administration has made Brunson’s case a top priority for the U.S.-Turkey relationship. Erdogan had hoped to exchange Brunson for Pennsylvania-based cleric Fetullah Gulen, whom he has accused of orchestrating the 2016 coup attempt, but the pastor’s detention instead served to stoke U.S. frustration with Turkey’s lurch toward authoritarian rule.

“There is no credible evidence against him,” Vice President Mike Pence said at a summit on religious freedom in July. "If Turkey does not take immediate action to free this innocent man of faith and send him home to America, the United States will impose significant sanctions on Turkey until Pastor Andrew Brunson is free.”

The administration subsequently imposed sanctions on two senior Turkish officials. Trump also tweeted that he had “authorized a doubling” of steel and aluminum tariffs on the NATO ally. Erdogan accused the United States of waging economic war on his government, but the Turkish currency’s value had been plummeting even before Trump’s slap.