WASHINGTON — As Trump administration officials presided over the second day of an international conference in Warsaw dominated by calls to ratchet up pressure on Iran, one longtime U.S. ally and NATO member was noticeably absent — Turkey.

Snubbing the gathering in Poland, Turkish President Recep Tayyip Erdogan on Thursday attended a rival conference in the Black Sea resort of Sochi, where he planned to meet his Russian and Iranian counterparts to work out a final settlement of the war in Syria.

The dueling summits illustrate President Donald Trump's struggle to forge a united front against Iran, and reflect Turkey's drift away from Washington as it finds common ground with Moscow and Tehran, experts and former officials said.

For decades, the U.S. could count on Turkey as a reliable partner that would line up with other allies against Iran and support Washington's strategic goals. But the political landscape has changed, U.S. influence in the region is in doubt, and Ankara is staking out an independent course, said Colin Clarke, senior research fellow at the Soufan Center, a New York-based think tank.

"I think we're seeing a realignment," Clarke told NBC News. "The U.S. has gone from the position where we called the shots, to where we are making mere suggestions to Turkey. That's a major sea change."

Turkey's relations with Washington have come under mounting strain since Erdogan was elected president in 2014, as the Turkish leader has pushed back on U.S. policies and carried out a crackdown on dissent. But the conflict in Syria has opened up the most dramatic divide between the two countries, with Ankara infuriated at Washington's support for Kurdish forces in Syria, which it sees as a terrorist threat.

When national security adviser John Bolton flew to Ankara in January, Erdogan refused to meet him and expressed outrage at U.S. demands that Turkey refrain from launching strikes against Kurdish fighters in northeastern Syria.

Civilians wait at a makeshift checkpoint after fleeing ISIS from the Syrian city of Bagouz on Feb. 9, 2019. Chris McGrath / Getty Images

"We cannot swallow . . . the message that Bolton gave in Israel," the Turkish president said, and added that Bolton "probably doesn't know" the difference between ethnic Kurds and armed Kurdish groups.

With the U.S. planning to withdraw its small contingent of 2,000 troops in Syria within months, Turkey has recognized for some time it must reach an accommodation with Russia and Iran to safeguard its interests in Syria, experts said.

"The real power brokers in Syria are Iran and Russia," said Ilan Goldenberg, a former senior official under the Obama administration and now a senior fellow at the Center for a New American Security, a think tank.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The three countries meeting in Sochi have emerged as the dominant players in what appears to be the final phase of the Syrian civil war. Russia and Iran came to the aid of the Syrian regime of Bashar al-Assad and have succeeded in turning the tide of the conflict in Assad's favor.

A Syrian Democratic Forces fighter stands guard on a rooftop after retaking the city of Raqqa from ISIS fighters on Oct. 20, 2017. Bulent Kilic / AFP/Getty Images file

Turkey cultivated Islamist rebel groups opposed to Assad that have been beaten back for the most part. But Russia and Iran need Turkey's help in squelching the rebels in their last strongholds in the northern province of Idlib, and Ankara needs Russian and Iranian cooperation to ensure Kurdish forces are kept in check and to pave the way for Syrian refugees to return, former U.S. diplomats said.

"I am confident that our trilateral summit on Syria will provide a new impulse toward stabilization in this country," Putin said before the talks began in Sochi.

In discussions with Ankara, U.S. officials have revived the idea of a protected "buffer zone" for the Kurds in the northeast, but Erdogan has said any such area would have to be coordinated with Russia.

When an uprising erupted in Syria in 2011, Erdogan had hoped to see Assad fall. But Turkey has since come to accept that Assad is firmly in place, and that the Syrian regime's patrons — Russia and Iran — will be needed to prevent a Kurdish state forming on Turkey's southern border, said Aykan Erdemir, a member of the Turkish parliament from 2011-2015.

Turkey's President Recep Tayyip Erdogan speaks to the media at the parliament in Ankara on Jan. 8, 2019. Burhan Ozbilici / AP

"Turkey realizes it has lost in Syria. And the Kurdish issue has always been the top priority for Turkey," said Erdemir, now a fellow at the Foundation for Defense of Democracies, a hawkish think tank. And that "means you have to work with Russia," he said.

As U.N. peace talks on Syria foundered in recent years despite backing from the United States, Turkey joined up with Russia and Iran for an alternative peace process that soon overshadowed the U.N. effort, a result that made the United States look impotent, foreign diplomats and experts said.

At a moment when Turkey's fragile economy is plagued by debt and inflation, Ankara is anxious to retain close economic cooperation with Moscow, as it relies on gas supplies from Russia and revenues from Russian tourists and from Turkish contractors in Russia, Erdemir said. After a Russian fighter jet was downed by Turkey in November 2015, Moscow banned charter vacation trips to the country, dealing a severe blow to Turkey's tourism industry.

Erdogan also sees Russia as an important alternative source for weapons. Ankara has ignored warnings from two successive U.S. administrations against buying the Russian-made S-400 missile system and Turkish officials say they plan to wrap up the purchase later this year.

Musa, a 25-year-old Kurdish marksman, stands atop a building as he looks at the destroyed Syrian town of Kobane, also known as Ain al-Arab, on Jan. 30, 2015. Kurdish forces recaptured the town on the Turkish frontier in a symbolic blow to the jihadists who have seized large swathes of territory in their onslaught across Syria and Iraq. Bulent Kilic / AFP - Getty Images file

Turkey is not alone in seeking to cultivate Russia, as other U.S. partners in the Middle East — including Egypt, Iraq, Lebanon, the United Arab Emirates — see Moscow as stepping into a vacuum left by the U.S., offering arms and energy deals.

"Everybody in the region is looking at Russia," Goldenberg said. "With their relatively small intervention in Syria, they were basically were able to turn the tide in a regional war."

Like Russia, Turkey has opposed the Trump administration's hardline on Iran, and Erdogan has threatened to defy the U.S. sanctions reimposed on Tehran, calling them an "imperial" policy. During the last round of sanctions that preceded the 2015 nuclear agreement with Iran, Turkey was accused of turning a blind eye to sanctions busting.

The Trump administration last year granted Turkey an exemption to allow it to purchase oil from Iran, though at lower levels. But it remains clear if the White House is ready to renew the waiver to Ankara later this year.

Erdogan's harsh treatment of political opponents, journalists and other critics, along with his preference for an Islamist political model at the expense of the country's secular traditions, has put him at odds with the United States and the European Union. But he has dismissed Western objections, and his supporters point out that the democracies of Europe refused to open the door to Turkey's request for EU membership for years.

Turkey has also bristled at America's close embrace of Riyadh, opposing Saudi Arabia's embargo on Qatar while competing with the kingdom to serve as the region's leading Sunni power.

When the Saudi writer Jamal Khashoggi was killed in Saudi Arabia's consulate in Istanbul in October, Erdogan's government leaked out damning details of the incident, forcing Riyadh to revise its official explanation more than once. "Turkey saw an opportunity to embarrass the Saudis, to gain leverage," Goldenberg said.

So far, Turkey has yet to pay a serious price for its disagreements with Washington and European powers. Congress has threatened to sanction Turkey if it goes ahead with acquiring the Russian-made S-400 missiles, and Trump threatened to imposed sanctions if Ankara crushed the Kurds in Syria. But Erdogan has calculated that the United States is not ready to hit its old ally hard with punitive measures, experts said.

"I think he believes he has impunity in relations with the EU and the U.S., " Erdemir said of the Turkish president. "Erdogan knows that Putin will push back, Iran will push back, but not the U.S."

Turkey has even sought to undercut the United States in Latin America, refusing to back U.S.-led sanctions on Venezuela and opposing Washington's effort to recognize opposition leader Juan Guaido. A month after the Trump administration granted an exemption for Ankara to allow it to continue to import Iranian oil, Erdogan paid a visit to Venezuela in December to lend his support to the regime of President Nicolas Maduro.

"That's pretty extraordinary," said Eric Edelman, a former U.S. ambassador to Turkey now with the Center for Strategic and Budgetary Assessments think tank. "It's impossible to imagine any previous Turkish leader doing that."