The Sunni-Shiite civil wars in Iraq and Syria are both nearing their end, and in both cases the Shiites have won — thanks largely to American military help in Iraq’s case, and to a Russian military intervention in Syria. Yet Russia and the United States are not allies in the Middle East. At least not yet.

U.S. President Donald Trump may get in bed with the Russians and the Shiites eventually, but he doesn’t seem to have given the matter much thought yet. So for the moment U.S. policy follows the line laid down by Barack Obama.

U.S. President Barack Obama was determined not to send American troops into another Middle Eastern war. Even as the Sunni extremists of Islamic State and the Nusra Front (al-Qaida under another name) expanded their control in Syria and then seized much of Iraq, Obama restricted the U.S. intervention to training local troops and deploying American air power.

In Iraq the government’s troops were mostly Shiite (as is most of the population), and U.S. support was sufficient without committing American troops to ground combat. The Iraqi Army is now in the final stages of reconquering Mosul, the Islamic State militant group’s capital in Iraq and an almost entirely Sunni city. Yet there have been no massacres of Sunnis, and only a handful of American casualties.

In Syria, the U.S. strongly opposed the Shiite-dominated regime of President Bashar Assad, but it did not fight him. Obama found local allies to wage a ground war against Islamic State in the form of the Syrian Kurds, who are Sunni but are more interested in a separate Kurdish state than a Sunni-ruled Syria.

That collaboration worked well, too. With U.S. training and air support, the Syrian Kurds drove Islamic State steadily back, and are now closing in on Raqqa, its capital in Syria. And in all that time, Obama avoided taking sides between Shiites and Sunnis in what most Arabs now see as a Shiite-Sunni war.

Obama even managed to maintain America’s traditional alliances with Saudi Arabia and Turkey despite the fact that those two countries, both ruled by devout Sunni regimes, were sending money and arms to the extremists of Islamic State and the Nusra Front. He successfully walked a fine line in the Middle East for six whole years.

It’s doubtful that Trump has the skill, knowledge and patience to go on walking that line. His instinct is to treat Iran as America’s most dangerous enemy in the Middle East, which would certainly please Saudi Arabia. But Iran is Russia’s close ally in the Syrian war, and Trump’s instinct is also to get very close to Russian President Vladimir Putin.

There’s a similar problem with Turkey. On one hand, Turkey is an important NATO ally and it has now sent its army into Syria, ostensibly to help destroy Islamic State.

On the other hand, Turkey is ruled by the authoritarian and impulsive President Recep Tayyip Erdogan, a mini-Trump who sprays abuse at anybody who crosses him (he recently called the Germans “Nazis” and the Dutch “Nazi remnants and fascists”).

In 2015, Erdogan deliberately re-started a war against Turkey’s own Kurdish minority in order to attract right-wing votes and win a close election. Now he has sent the Turkish Army into Syria, allegedly to help destroy Islamic State but in fact mainly to smash the embryonic state that the Syrian Kurds have been building across northern Syria. Those Syrian Kurds have been America’s closest allies against Islamic State for years.

There are even Turkish troops in northern Iraq (without permission), and Erdogan has threatened to use them if the Iraqi Army abuses Sunni Muslims during the reconquest of Mosul. Iraqi Prime Minister Haider al-Abadi replied (in November): “We do not want war with Turkey … but if a confrontation happens we are ready for it.”

Erdogan has gone rogue, and Turkey’s recent, quite fragile reconciliation with Russia is not restraining him. The two countries, together with Iran, are jointly supervising the shaky cease-fire in Syria, but they do not share the same goals and they are not really allies.

Into the midst of all this vicious complexity wanders the boy-man Trump, with his full-spectrum ignorance, short attention span and shorter temper. His appointee as national security adviser, Gen. Michael Flynn, doubtless advised him to support Turkey’s ambitions, but Flynn had to resign and it was revealed that he was in the pay of the Turkish government.

If Trump cozies up to the Russians instead, he will have to accept a close relationship with Assad’s brutal regime in Syria (no problem there) and also with Russia’s main ally in the Syrian war, Iran (potentially a big problem there). But various latent conflicts are likely to burst into flame as the big civil wars in Iraq and Syria stagger to an end. Trump will have to jump one way or another quite soon.

Gwynne Dyer is an independent journalist and military historian whose articles are published in 45 countries.