(Bloomberg) -- Turkey’s release of U.S. Pastor Andrew Brunson settles an issue that pushed ties between the countries to new lows, but it left unresolved tensions that continue to undermine relations between the two NATO allies.

After almost two years in prison and house arrest, a Turkish court’s decision Friday means Brunson is returning to the U.S., where the evangelical pastor’s case was championed by Vice President Mike Pence and Secretary of State Michael Pompeo. Turkey had charged Brunson with aiding people involved in a failed 2016 coup against President Recep Tayyip Erdogan, accusations the U.S. rejected.

Brunson, 50, left Turkey late on Friday and was expected back in the U.S. on Saturday. Trump said that the pastor appeared to be “in good shape” and will have a medical checkup in Germany before continuing on to the U.S.

“He suffered greatly but we’re very appreciative to a lot of people,” Trump said Friday in Cincinnati on his way to a campaign rally. “There was no deal made” for Brunson’s release, he said.

Trump’s frustration over Brunson’s continued detention became the dominant issue between the U.S. and Turkey in recent months. It prompted Trump to double metal tariffs on Turkey in August, fueling a weakening of the lira, and impose financial sanctions on key Erdogan aides involved in the pastor’s case.

“This had to happen for things to just hold,” said Max Hoffman, associate director for national security and international policy at the Center for American Progress in Washington. “If he hadn’t been released there were going to be new sanctions or additional sanctions and the tailspin would continue. So at least we’ve stopped the deterioration.”

A court in Izmir convicted Brunson and sentenced him to three years, one month and 15 days in jail but lifted all judicial controls and released him after accounting for penalty reductions and time served. He had already been transferred to house arrest in July because of poor health, but U.S. officials had expected him to be freed then.

The standoff between Trump and Erdogan, two leaders known for not wanting to back down publicly, had appeared to be at a stalemate. But one analyst suggested the economic cost to Turkey made the dispute untenable.

“Given how fragile Turkey’s economy is, Erdogan knows this will reflect positively on the Turkish economy and the currency,” said Aykan Erdemir, a senior fellow at the Foundation for Defense of Democracies in Washington. “That could be the payoff -- avoiding further political and economic problems.”

Islamic State

Officials have hoped Brunson’s release could serve as a catalyst for improving ties between Turkey and the U.S. Turkey has played a key role in the fight against Islamic State in neighboring Syria and has the second-biggest military in the North Atlantic Treaty Organization.

Yet there are still significant grievances between the two countries. Erdogan hasn’t stepped back from plans to buy a Russian missile defense system, the S-400, that isn’t compatible with NATO requirements. That has fueled demands in the U.S. that planned deliveries of F-35 jets be put on hold even though portions of the Lockheed Martin Co. fighter are being built in Turkey.

In addition, at least three other people detained in Turkey have attracted Washington’s attention and fueled strains. They include NASA scientist Serkan Golge and three Turkish employees of the U.S. mission to Turkey. The U.S. says they’re innocent.

“We remain deeply concerned about the continued detention of other United States citizens in Turkey and around the world, and urge the resolution of all these cases in a transparent and fair manner,” White House press secretary Sarah Huckabee Sanders said in a statement welcoming Brunson’s release.

Lira’s Fall

“While we are relieved by today’s decision on Pastor Brunson’s unjust detention, we remain concerned for the Turkish people," the U.S. Commission on International Religious Freedom said in a statement on Friday. “Turkey must continue to work to treat all of its citizens equally and with respect for their religious freedom."

Before Brunson’s release, Turkish officials had been seeking meetings with the U.S. to negotiate a resolution to his case and other issues, but National Security Adviser John Bolton declared in August that no such talks would proceed until Brunson was let go. In the meantime, Turkey’s lira continued its fall, losing about 25 percent of its value in August alone.

While Trump said no concessions were made to Turkey to secure Brunson’s release, the question is whether the U.S. will move on its own to ease sanctions imposed in recent months that have added to the difficulties facing the country’s economy.

From Turkey’s side, the U.S. hasn’t shown any movement toward meeting Erdogan’s long-standing demand to extradite Fethullah Gulen, a prominent Turkish cleric living in exile in the U.S. whom Erdogan has blamed for the coup. Gulen denies involvement in the coup attempt. Also outstanding: the fate of Mehmet Hakan Atilla, a Halkbank executive sentenced to prison in the U.S. for violating Iran sanctions. Erdogan has ridiculed the conviction and called for Atilla to be set free.

But Brunson’s release eliminates an embarrassing, if temporary, defeat for Trump, who believed he had an agreement with Erdogan for the pastor to be released months ago, only to see it fall apart. It shows that despite continuing grievances, the two countries can overcome their mutual suspicion in some cases.

The move also hands Trump a victory that will be favorably viewed by his evangelical political base ahead of midterm elections next month. And it allows the president to focus more on another escalating foreign policy crisis: relations with Saudi Arabia.

The kingdom is increasingly under fire amid charges -- from Turkey -- that it lured a prominent critic and U.S. resident into its consulate in Istanbul and killed him. The accusations have been rejected in Riyadh but are threatening to undermine relations with an ally the president has courted assiduously since making his first foreign trip to Saudi Arabia in May last year.

Trump turned his attention to the Saudi dispute in comments to reporters on Friday, after announcing that Brunson was on his way back to the U.S.

“This is a serious problem,” Trump said of the Saudi controversy. “This is a very serious thing.”

--With assistance from Selcan Hacaoglu.

To contact the reporters on this story: Nick Wadhams in Washington at nwadhams@bloomberg.net;Cagan Koc in Istanbul at ckoc2@bloomberg.net;Onur Ant in Ankara at oant@bloomberg.net

To contact the editors responsible for this story: Bill Faries at wfaries@bloomberg.net, Larry Liebert

©2018 Bloomberg L.P.