For more than three decades, Turkey has been pounding on the gates of Europe, desperately, at times frantically, seeking entry to the European Union. Turkey believed it had earned the right to be in the EU, and indeed, a decade ago Turkey’s economic growth and prospects were substantially more solid than any number of nations Europe had recently admitted. Turkey had also been a loyal member of the NATO alliance since 1952. But, alas, no matter how loudly and persistently it sought entry to the European Union, there was never any answer.

Eventually, Turkey’s hopes waned. Instead, it turned its attention toward the Arab world, opening new avenues for trade and investment with nations to its south and west, particularly Saudi Arabia and Qatar. Turkey also opposed NATO intervention in Libya. And for a time, and despite the objections of European nations anxious for Turkey to turn off the flow of Syrian migrants through its territory and onward to Europe, Ankara continued to offer a safety-valve for hundreds of thousands of people driven out of Syria by the civil war.

Still, Turkey never gave up completely on Europe, as its handling of the probe investigating Saudi journalist Jamal Khashoggi's killing suggests.

One of the deep ironies of the Khashoggi investigation is that more journalists reportedly remain imprisoned in Turkey than any other nation.

Turkey has spent the past decade attempting to put in place the economic and political reforms demanded by European leaders, with mixed results. Indeed, the latest annual report in April by the European Commission on Turkey’s progress toward membership said bluntly that Turkey was taking huge strides in the opposite direction. Turkish President Recep Tayyip Erdoğan has also endured a slew of negative headlines in the Western press,with pressure intensifying after a failed coup in 2016 resulted in a massive crackdown. Indeed one of the deep ironies of the Khashoggi investigation is that more journalists reportedly remain imprisoned in Turkey than any other nation, according to a 2017 Committee to Protect Journalists report. Erdogan's government has also shuttered more than 150 media outlets.

But now, suddenly an all but unparalleled and certainly unanticipated opportunity has presented itself — the murder and dismemberment of Jamal Khashoggi in the Saudi consulate in Istanbul. Erdoğan appears quite eager to pounce on this opportunity, disclosing any number of details of the Turkish investigation. As a result, the press has kept the pressure on Saudi Arabia and governments that do business with it, including Trump's White House.

With Saudi Arabia having cooled on closer relations with Turkey, especially as Erdoğan has failed to break with Riyadh’s arch enemy Qatar, there seems to have been little to restrain Erdogan from yet another effort to tilt toward Europe, if not the United States.

While Trump spent days waffling on the culpability of Saudi royals, Erdoğan jumped in whole hog. The evidence of Saudi foul play seems clear, but it’s unlikely Turkey is motivated merely by the search for truth.

Erdoğan's decision is not without some risk, though. It could place any future Turkish ties with Saudi Arabia and Saudi friends in the Middle East in serious jeopardy. Several Middle Eastern nations have already sprung to the Saudis’ defense. Until now, Turkey’s frayed relations with the Saudis themselves had not yet reached the breaking point. As recently as 2015, Turkey was a card-carrying member of the Saudi-led Arab coalition to destroy ISIS.

But most of these nations have long viewed Turkey with suspicion, if not outright hostility. The corrupt, often brutal rule the Ottoman Turks exerted over many of these states for half a millennium has never truly been forgotten or forgiven. Now, Turkey seems to be again on the verge of rupturing whatever goodwill it had managed to establish in the Arab world.

So, Turkey’s current geopolitical posturing probably isn’t likely designed to make its neighbors happy. However, there is far more at stake with respect to American interests in the region. Together with the United States, Saudi Arabia has been an important lynchpin in efforts to counter Iranian activities. While Saudi Arabia was a firm supporter of Trump’s withdrawal from the Iranian nuclear agreement, Turkey has positioned itself on the side of Iran, again earning points from the leading Western signatories of the pact — Britain, France and Germany, as well as Russia.

At the same time, Erdoğan has made a major effort to establish close ties with Russian President Vladimir Putin, the two meeting three times in three weeks this summer — a new friendship that could not have been lost on Trump. Iran and the role Russia is playing in Syria were reportedly central to these discussions.

Lately, and perhaps of greatest long-term importance to America’s interests in the region, Turkey’s role as a go-between with Russia and Iran helped lead to a reduction in fighting in parts of northern Syria as Turkey sought to make good on a pledge to Russia to disarm some of the rebel factions it has supported. This conflict, that promised earlier this year to become the last major bloodbath in that country’s civil war has since cooled considerably, at least for the moment — again playing into Trump’s deep interest in disengaging with some degree of honor from that conflict.

The U.S. president may have to keep playing the complex three-dimensional chess game into which his Saudi allies and Turkey have thrust him.

But now with both Saudi Arabia and Trump belatedly conceding Jamal Khashoggi is dead, it would appear that the U.S. president may have to keep playing, in some fashion, the complex three-dimensional chess game into which his Saudi allies and Turkey have thrust him. Moreover, while Trump has tied his fortunes in the region heavily to Saudi Arabia, its arms purchases and its hammerlock on the oil market, he cannot be entirely unhappy that it’s Turkey and Erdoğan — who he fist-bumped and called his “great friend” as recently as July — is playing such a key role here.

Turkey knows what it stands to gain by positioning itself as a truth-teller and defender of human rights in the region. But just how deftly Trump manages his own chess moves and how carefully he chooses his partners going forward could be critical to establishing a viable solution to a host of challenges in this region.