WASHINGTON — President Trump has long sought to avoid confronting the leaders of Turkey and Russia — two foreign strongmen who are facing off in civil wars in Syria and Libya. But after an airstrike on Thursday that killed dozens of Turkish troops in northwest Syria, Mr. Trump may be forced to pick a side.

Nominal allies, President Vladimir V. Putin of Russia and President Recep Tayyip Erdogan of Turkey have each thrown military forces and other support into two bloody conflicts that have spawned vast human suffering, have threatened to upend a fragile stability in the Middle East and may send hundreds of thousands of refugees streaming into Europe.

Despite international calls for more American involvement, Mr. Trump has stood aside from significant intervention in either conflict — a decision consistent with his pledge to wind down the “endless wars” of the past two decades.

But State Department officials have made clear they view Russia as stirring the unrest, especially in Syria. Turkish leaders, well aware that their nation is viewed with distrust by many in Congress and within the NATO alliance, are seeking to use both conflicts to show the United States that they should put aside a year of strained diplomacy and unite against a common adversary: Moscow.