For most governments, a murder on their soil inside a foreign consulate would be a nightmarish problem. A problem fraught with investigative complexity, diplomatic risk, and the potential of international embarrassment.

Not for President Recep Tayyip Erdogan of Turkey.

Having witnessed Saudi Arabia's murder of Jamal Khashoggi in the Saudi consulate in Istanbul — Erdogan's local center of power — the Turkish leader has found a grand opportunity. Enter Saudi Crown Prince Mohammed bin Salman. Erdogan views bin Salman as his primary competitor for the global mantle of Sunni-Islamic leadership. And determined to become a kind of neo-Ottoman emperor, Erdogan knows that anything that makes bin Salman look bad is good for him. Indeed, for a ruler of questionable emotional stability such as Erdogan, Khashoggi's plight is an almost too-perfect gift.

After all, it offers Erdogan the means to earn Saudi deference while simultaneously imposing costs on Saudi credibility. On the deference count, the key factor is that Erdogan knows that Saudis know that he knows who is ultimately responsible for Khashoggi's death. Namely, Mohammed bin Salman. In turn, the Saudis are desperate to avoid Erdogan's publication of evidence that would point to bin Salman's culpability. Erdogan may not have this evidence, but the Western intelligence community does. And we should note that Erdogan chose his words very deliberately on Tuesday when he demanded Turkey identify everyone involved in Khashoggi's killing. This complement, Erdogan said, had to include the "one giving the order to the one who carried it out...."

Be under no illusions: That is a warning shot to bin Salman that he had better play nice with Erdogan in the future. Or if not, he should prepare to face harsh consequences for not doing so.

But that's just the start. Because by playing off the global fury that has met Khashoggi’s untimely demise, Erdogan is able to portray himself as an unlikely humanitarian or, at the very least, a not-so-bad leader. He hopes this will allow him to draw international investors and favor away from Saudi Arabia in a way that doesn't necessarily implicate Turkey as the agent of that decline. The underlying motivation here of making Turkey look comparatively better is further fueled by Erdogan's recent foreign policy debacles. Erdogan has grudgingly recognized, for example, that Russian President Vladimir Putin has played him for a fool in Syria. He also appears to be realizing that his multiyear diplomatic breach with America was a mistake. But in Erdogan's eyes, the beauty of Khashoggi's killing (Erdogan is not a nice guy) is that the Saudis have no room to maneuver or otherwise deflect criticism onto anyone else. Put simply, this is a whirlwind wholly of Saudi Arabia's own making.

Even then, Erdogan knows that he must strike a balanced line with the Saudis. Riyadh is already furious with Erdogan for what it regards as his excessive support for Islamist movements beyond Saudi control. But with the Turkish economy struggling, Erdogan has little appetite for punitive Saudi economic measures. For the Turkish leader, then, the great balancing act is extracting maximum concessions from Saudi Arabia, bringing significant negative attention to Saudi Arabia, but also avoiding a complete diplomatic breach with Saudi Arabia. That's why Erdogan is putting the ball in bin Salman's court as to whether he wants to play hardball or not. Both sides, Erdogan ventures, will choose Erdogan's blackmail choice.