As Turkish forces along the Syrian border exchange fire with the army of Bashar Assad, and Syrian refugees pour into Turkey, Prime Minister Recep Tayyip Erdogan, a proud Islamist, might better appreciate the wisdom of Mustafa Kemal Atatürk. The secular founder of modern Turkey advised his countrymen: Look West, leave the old lands of the Ottoman Empire to their feuds and backwardness.
For Mr. Erdogan, so near the Syrian killing fields in Aleppo and Idlib, there is now no easy way out of this entanglement. The conflict escalated on Oct. 3, when Syrian mortar shells hit a Turkish border town, killing five civilians—a woman and four children—and prompting Mr. Erdogan to warn: "We're not interested in war, but we're not far from it either."
Not far, indeed. In June, the Assad regime downed a Turkish F-4 fighter jet it claimed was over Syrian "territorial waters," causing outrage in Ankara. This week, Turkish jets forced down a Syrian passenger plane that Ankara suspected of transporting military equipment from Russia. Mr. Erdogan announced on Thursday that the plane was carrying ammunition and defense equipment bound for the Assad regime in violation of an arms embargo. NATO recently announced that it has drawn up plans to defend Turkey, a member since 1952, if necessary.
Damascus and Ankara have been at odds for some time. The rebellions that broke upon the Arab world in 2010-11 presented Mr. Erdogan with a grand temptation. Those countries that had risen in revolt had been old, Ottoman provinces. For centuries, until the end of World War I, Tunisia, Egypt, Libya and even more so neighboring Syria had been ruled from Istanbul. Now the doctrines of Arab nationalism that had guided them have come undone.
For the Muslim Brotherhood in these Arab countries, the triumph of Turkey's Islamists at the ballot box in the past decade, Turkey's phenomenal economic success, the authority that Mr. Erdogan has carved out for himself on the world stage—it was all a model to emulate. The Arab (read Sunni) street had been in search of a hero, and Mr. Erdogan was eager to play the part.
In truth, Mr. Erdogan, and the industrialists and business interests around him, were not indiscriminate enthusiasts of the Arab Spring. Mr. Erdogan had to be dragged into the fight against Libyan dictator Moammar Gadhafi. Turkey has substantial investments in Libya, and the prime minister was loath to sacrifice them. But he went along with the NATO campaign, and later went on a victory tour of Tunisia, Egypt and Libya. To believers this was the second coming of the Ottoman sultanate.
Syria, though, was a case apart. Mr. Erdogan hoped against hope initially that the rebellion against the Assad regime would blow over. A shrewd politician, he understood that he could not be the flag-bearer of this Islamist awakening and an ally of Bashar Assad at the same time.
Mr. Erdogan and his foreign minister, Ahmet Davutoglu, had proclaimed a foreign policy of "zero problems with neighbors." But they lived in a bad neighborhood. The tyrant in Damascus had hunkered down, and the rebellion against him would not die.
Assad's war on his own (mostly Sunni) citizens had triggered a larger sectarian war, a Sunni-Shiite schism. For those who love such images, it was a struggle between the "Shiite Crescent," stretching from Iran and Iraq to Syria and Hezbollah's reign in Beirut, versus a Sunni bloc from North Africa to the eastern Mediterranean, clustered around Turkey, Egypt and Saudi Arabia.
Syria is the prize, and the epicenter, of this contest. Hard as Mr. Erdogan would try to keep the struggle for Syria within tolerable bounds, the cruelty of the civil war there would overwhelm his policy. He had pledged himself to the removal of Assad, but the dictator had not obliged. Nor had Washington—particularly President Obama, obsessed with self-preservation—been the ally Mr. Erdogan had hoped for. As the fighting dragged on and the refugees came, the Turks discovered that it is never easy being a sanctuary for dispossessed people bent on retrieving what they've lost.
Mr. Erdogan is a dominant figure in his country, but democracy imposes its limits. When the prime minister went to the National Assembly for a vote authorizing strikes into Syrian territory after the recent mortar attacks, he was given what he sought. But this was no rubber-stamp parliament—the vote was 320 in favor and 129 against. The principal opposition, the Republican People's Party, and the Kurdish representatives, cast their votes against.
In our received history, we think of conquering Turkish soldiers forging an empire with the sword, knocking at the gates of Vienna, but this is now history. There is a dominant pacifism in the country. Opinion polls show that an overwhelming majority of Turks oppose unilateral military intervention in Syria. Two-thirds of the Turkish public want the traffic of Syrian refugees to be brought to a halt. In fairness, Turkey's decent treatment of the refugees puts to shame the way Syria's Arab neighbors have dealt with refugees.
"One has to be ready for war at every moment, if it becomes necessary," the Turkish prime minister said recently. "If you are not ready, you are not a state and cannot be a nation." But Turkey is also a NATO member of long standing. The Turks' burden in Syria could be eased if NATO established a no-fly zone within Syria. But that would require strong U.S. leadership, which is sorely lacking of late.
On the face of it, the Turkish state will not be drawn into a war with the Syrian regime. The promise of Mr. Erdogan's order has been the provision of prosperity for his population. A war that would undermine Turkey's trade and tourism is anathema to the rulers in Ankara. But it could still come to war, especially if Assad grants the Kurdish terrorist organization, the PKK, sworn enemy of Ankara, free run in Syrian Kurdistan.
It didn't have to come to this terrible choice: a big war or acquiescence in the face of Assad's crimes. A resolute American policy could have toppled the Syrian regime, without boots on the ground. We might have spared the Turks this insoluble dilemma. We surely could have spared the Syrians the bloodletting—some 30,000 lives in 18 months—that wrecked and radicalized their country.
Mr. Ajami is a senior fellow at Stanford's Hoover Institution and the author of "The Syrian Rebellion" (Hoover Institution Press, 2012).