The Trump administration is cautiously optimistic that an American cleric who has been held in Turkey for the past
two years on espionage and ­terrorism-related charges will be released soon after a court hearing Friday, according to U.S. officials and people close to the case.

In a negotiated deal that includes the lifting of U.S. sanctions — both threatened and implemented — against Turkey, charges against the Rev. Andrew Brunson are to be reduced to allow him to be sentenced to time already served, or to be allowed to serve any remaining sentence in the United States.

The agreement — part of which was negotiated at last month’s U.N. General Assembly meeting, attended by President Trump and Turkish President Recep Tayyip Erdogan — will lead either to Brunson’s immediate release Friday or his freeing within a few days, said officials who spoke on the condition of anonymity to discuss the still-secret arrangement.

In a speech Wednesday night, Secretary of State Mike Pompeo said the administration was “very hopeful that we’ll see a good outcome before too long.”

A spokesman for the Turkish Embassy in Washington said it was “not in a position to comment on an ongoing judicial process.”

The return of Brunson, whose case has been an intense focus of Trump’s evangelical political base, would be a major victory for the president. The administration would likely cast it as proof of the wisdom of his hard-line stance against Turkey, a NATO ally, and his commitment to protecting besieged Christians around the world.

Resolution could also mark a turning point in relations between the two governments. They have been especially fraught in recent years, marked by mutual mistrust and charges of bad faith despite a range of shared interests and extensive military and security ties.

A European diplomat who closely follows the subject predicted that Brunson would be convicted of supporting a terrorist organization, sentenced to four or five years, then credited for time served and expelled from Turkey.

“For Erdogan, it’s important that he’s not seen as giving in to U.S. pressure, that he lets the judicial process take its course and he shows that Brunson is guilty,” said the diplomat, who also spoke on the condition of anonymity about the arrangement.

U.S. officials remained cautious, however, in light of a deal that fell apart last summer, after which each side accused the other of bad faith.

Brunson, who has lived in Turkey for more than two decades, was arrested in a sweep of thousands that took place after an unsuccessful coup attempt in 2016. Charges against him, which he and the Trump administration have said are bogus, include contacts with the so-called coup mastermind, Turkish cleric Fethullah Gulen, a permanent U.S. resident living in Pennsylvania and a longtime political foe of Erdogan. The indictment against Brunson also charges him with having contact with Kurdish separatists that Turkey and the United States have designated as terrorists.

After repeated efforts to arrange his freedom were unsuccessful, Trump and Erdogan, with only interpreters present, discussed the issue at the NATO summit in July. Reports of what transpired were vague, and the two sides later had differing versions of what the leaders agreed upon.

Trump came away believing Erdogan was prepared to “help him out” in arranging Brunson’s release, according to a White House official, in exchange for Trump’s intervention with Israel to free a Turkish national being held there on charges of aiding Hamas.

Turkish officials later said that they had discussed a step-by-step process that would eventually lead to the pastor’s release, but that no specific ask was made and the Israeli release had only been mentioned in passing.

Erdogan has repeatedly demanded extradition of Gulen, which U.S. officials have said is unjustified based on evidence Turkey has so far presented of alleged coup plotting. Turkey also seeks the release of Mehmet Hakan Atilla, a Turkish banker convicted in May of taking part in a massive scheme to violate U.S. sanctions on the purchase of Iranian oil. The high-profile federal trial also involved Halkbank, a Turkish state bank, which is still awaiting court determination of what could be a multibillion-
dollar fine.

U.S. officials charged that the Turks had brought up all these issues, raising the ante for Brunson’s release, after Trump upheld his side of the bargain and obtained the release from Israel.

Within hours after a Turkish court in late July ordered Brunson released from jail but held under house arrest, Trump publicly threatened sanctions.

In short order, tit-for-tat sanctions were declared on senior officials on both sides, and Trump announced that he was doubling U.S. tariffs on Turkish steel to 50 percent, and on Turkish aluminum to 20 percent. “Our relations with Turkey are not good at this time!” he tweeted.

Turkey’s economy, already in difficulty, went into a tailspin. Congress, where anti-Turkey sentiment over the Brunson case has been high, passed legislation freezing the sale of 100 F-35 aircraft to Turkey and giving Defense Secretary Jim Mattis — who opposed the freeze — until November to prepare a report on how it would affect U.S. security and the defense industry.

Turkey insisted it would move ahead with the purchase of a sophisticated Russian antimissile defense system, despite threatened U.S. sanctions and expressions of concern from NATO. Another potential crisis looms when new U.S. sanctions against purchases of oil from Iran, Turkey’s second-largest supplier, go into effect Nov. 4. The administration has said it will make no exceptions.

But tempers have cooled somewhat on other issues, as the United States and Turkey have addressed some of their differences over Syria, and have shared their disquiet over last week’s disappearance of Jamal Khashoggi, a dissident Saudi journalist, during a visit to the Saudi Arabian Consulate in Istanbul.

Turkish officials have said they think Khashoggi was killed there, perhaps in a botched attempt by Saudi agents to kidnap and interrogate him. Trump has expressed “concern,” but the administration has declined to accuse Riyadh directly, saying it is awaiting more information. Saudi Arabia has denied involvement in Khashoggi’s disappearance and said he left the consulate soon after entering.

John Hudson contributed to this report.