ISTANBUL — Saudi Arabia’s decision to acknowledge the death of Saudi journalist Jamal Khashoggi followed calls for justice from around the world. But no individual had put more pressure on the oil-rich monarchy than Turkish President Recep Tayyip Erdogan.

In the weeks after Khashoggi disappeared at the Saudi Consulate in Istanbul, Erdogan and his aides did more than just quietly investigate: They narrated the crisis, focusing the world’s attention on what they said was a brazen, state-sponsored assassination on its soil.

Grisly details of the alleged killing were released to the Turkish and international news media. Erdogan publicly upbraided Saudi Arabia’s leaders, accusing them of obstructing the probe.

Turkey’s revelations may have helped push the Saudi government to reverse its repeated denials of wrongdoing and announce early Saturday that it had arrested 18 people and fired several top officials in the case. Saudi officials said Khashoggi was killed in a fight inside the consulate.

In a final act of Turkish pressure, prosecutors said Friday that they were interviewing Turks who worked at the consulate — employees who might have insight into the movements and actions of Saudi officials around the time Khashoggi disappeared.

Turkey’s foreign minister, Mevlut Cavusoglu, also warned that when Turkey completed its investigation, it would share the results “with the world.”

For Erdogan, the benefits of turning up the heat on Saudi Arabia and its young crown prince, Mohammed bin Salman, were apparent, analysts said. The two countries have competed for influence in the Middle East and clashed over Turkey’s support for Qatar in a feud that divided the region.

Erdogan has little personal affection for Mohammed, who referred to Turkey this year as part of a regional “triangle of evil,” along with Iran and regional Islamist groups. The Khashoggi investigation, with its allegations of high-level collusion by Saudi officials, provided Turkey an opportunity to damage the crown prince’s reputation, analysts said, and to drive a wedge between Saudi Arabia and the United States.

The Turkish president has also said he regarded Khashoggi as “a friend.”

Erdogan may be seeking other leverage for Turkey as well, including preventing Saudi meddling in Syria along Turkey’s border, and financial aid or relief from either the United States or the Saudis, analysts said.

The crisis provided a measure of respite for Turkey, at a time when Erdogan was facing criticism at home because of the ailing Turkish economy and criticism abroad for detaining foreign nationals and engaging in “hostage diplomacy.”

Instead, Khashoggi’s case thrust Erdogan into the ironic role of defender of journalistic freedom and dealmaker between the United States and Saudi Arabia as the two longtime allies have sought to manage the blowback over what many have concluded was Riyadh’s unrepentant killing of a prominent critic.

If Khashoggi’s status as a veteran journalist who wrote for The Washington Post first helped elevate his case from local mystery to global crisis, Turkey’s response amplified his plight.

Four days after Khashoggi’s disappearance on Oct. 2, Turkish officials shared their explosive conclusions with the news media: He had been killed soon after he entered the consulate to obtain papers that proved he was divorced. His murder, the investigators added, was at the hands of a 15-man “hit team” dispatched from Riyadh to silence Khashoggi, who had written columns in The Post criticizing the crown prince.

Leaks about the case seemed to dry up about a week ago. But they started again, more lurid than before, after Trump speculated that “rogue killers” were responsible for Khashoggi’s disappearance and as Secretary of State Mike Pompeo traveled to Riyadh, the Saudi capital, and was photographed smiling next to the crown prince.

The leaks fueled speculation that Erdogan was raising the cost of his government’s cooperation with Saudi Arabia, which badly wants to put the Khashoggi incident behind it.

U.S. officials had expected Saudi Arabia to take responsibility for Khashoggi’s death but to explain it in a way that shielded the crown prince from responsibility.

The announcement early Saturday in Riyadh appeared to meet that criteria, though it immediately came under criticism from policymakers in Washington. Erdogan, however, can claim Riyadh dismissed two senior aides to the crown prince as a result of his pressure campaign and may be able to walk away satisfied.

“The Turks have leaked information in drips and drops, ultimately in my estimation to increase the price of settlement,” said Joshua Walker, a former Turkey specialist at the State Department. “Turkey has been in a tough economic situation since the summer, and as we have seen with its relationship with Qatar, it is not above leveraging its relationships,” he said, referring to a pledge by Qatar in August to invest $15 billion in the Turkish economy.

There is no indication that Erdogan has asked for monetary compensation or political favors from Riyadh, but Western diplomats suspected that Saudi Arabia would compensate Turkey if it blessed the kingdom’s explanation for Khashoggi’s disappearance — a payback that could come in the form of large-scale debt relief, strategic buyouts or other arrangements.

“Right now what Turkey needs most is financial support. The economy is still brittle, it hasn’t recovered from the crash of its currency this summer, and Turkey is expected to face a massive fine for Iran-related sanctions,” said Soner Cagaptay, a Turkey scholar at the Washington Institute for Near East Policy.

“Erdogan is a master of creating an opportunity out of a crisis,” he said. “He’s an excellent politician in that regard, and he’s looking for an opportunity.”

But Asli Aydintasbas, a fellow at the European Council on Foreign Relations, said that Turkey’s goals were primarily strategic and that it was looking, among other things, for a “readjustment of U.S. policy” that had relied heavily on the Saudi crown prince as the linchpin of the Trump administration’s strategy to isolate Iran.

“They don’t want the Americans to base their whole policy on Mohammed bin Salman,” she said, but at the same time, Turkey does not expect the United States to pivot from the alliance with Saudi Arabia. Turkey’s aim, she added, is to deter “the more thuggish behavior associated with Mohammed bin Salman and the United Arab Emirates,” a key Saudi ally.

But the leaks, and the pressure they created, carry risks for Turkey as it tries to avoid a total diplomatic break with the Saudis and worries about Saudi retaliation, analysts said.

Erdogan “doesn’t want to go it alone against the Saudis,” said Gonul Tol, the director of the Middle East Institute’s Center for Turkish Studies. “They want to frame this as a world problem.”

Pompeo on Thursday said he had asked the White House to give Saudi Arabia “a few more days to complete” its investigation, even as he came under fire for failing to get answers about Khashoggi’s fate in his fact-finding mission to Riyadh and Ankara this week.

The Saudi crown prince, in private discussions with U.S. officials, had vociferously denied any involvement in Khashoggi’s disappearance, saying he would never be so stupid as to order the type of assassination being alleged, according to diplomats familiar with the conversations, who spoke on the condition of anonymity to discuss the sensitive topic. Critics had accused the United States of buying the Saudis time to come up with a plausible scenario that exonerated the crown prince.

But as Turkish authorities continued to leak more gruesome details to the press, Trump took an increasingly dim view of the situation, acknowledging for the first time Thursday that he believed Khashoggi was no longer alive.

One day later, Saudi Arabia finally acknowledged Khashoggi’s death, more than two weeks after he disappeared.