KABUL — Iran and Russia have stepped up challenges to U.S. power in Afghanistan, American and Afghan officials say, seizing on the uncertainty of future U.S. policy to expand ties with the Taliban and weaken the country's Western-backed government.

The moves come as tensions have flared between the United States, Iran and Russia over the conflict in Syria, and officials worry the fallout could hurt Afghanistan's chances for peace. For years, Iran and Russia have pushed for a U.S. withdrawal.

Now, as the Taliban gains ground and the White House appears to lack a clear Afghan policy, Iran and Russia have boosted support for insurgents and sidelined the United States from regional diplomacy on the war.

Russia on Friday will host high-level talks on Afghanistan with Iranian, Pakistani, and Chinese diplomats, the Kremlin said. But the United States, irked by Moscow's recent outreach to the Taliban, has not confirmed whether it will attend.

Russia has "begun to publicly legitimize the Taliban" and recent Russian and Iranian actions in Afghanistan "are to undermine the United States and NATO," the top commander of U.S. Forces in Afghanistan, Gen. John Nicholson, said in Senate testimony in February.

The United States has roughly 8,400 troops in Afghanistan, the majority of which belong to the NATO mission to assist Afghan forces. The remainder are here as part of a counterterrorism operation to target al-Qaida and a local affiliate of the Islamic State.

Nicholson said Iran and Russia "are communicating about the efforts" to support Taliban insurgents, and that Russia has "become more assertive over the past year."

"We know there is a dialogue. We know there is a relationship between Iran and Russia" in Afghanistan, he said. And Iran, which shares a long, porous border with Afghanistan, "is directly supporting the Taliban" in the western part of the country, he said.

While Russia and Iran appear to be unlikely allies with a hard-line Sunni group such as the Taliban, the two countries have for years played the different sides of the conflict. Both supported the U.S.-backed ouster of the Taliban in 2001, and Iran was the chief benefactor of the anti-Taliban Northern Alliance.

But Iran and Russia eventually soured on the U.S. presence, which they both gradually saw as a threat.

"Iran is worried that with American troops in Afghanistan, the two militaries will end up confronting each other," said Mohammad Akram Arefi, an Iranian-educated politics professor at Katib University in Kabul.

"Iran also wants to revive its power in the region, by having influence over Afghanistan. And with America here, they can't have the type of influence they want," he said.

Russia, which also sees Afghanistan as part of its sphere of influence in Central Asia, has suggested that the Taliban are an effective bulwark the rise of the Islamic State. A local branch has staged deadly attacks but also struggled to gain a foothold beyond their base in the east.

In a swipe at the legitimacy of the Afghan government, Russia has questioned security forces' abilities to target the group. Still, Iran and Russia have both denied providing the Taliban with weapons or cash.

In an emailed statement this week, the Russian embassy in Kabul said that the claims were "absurd fabrications" designed to distract from the failure of the U.S. and NATO missions here.

There is "a continuing series of groundless accusations against Russia about alleged support of the Taliban," the embassy said.

A Taliban spokesman also called the allegations untrue.

"Our contacts with Russia are for political and diplomatic purposes only," spokesman Zabiullah Mujahid said in a phone interview. He did not say if Taliban representatives would be attending the Moscow talks.

But U.S. and Afghan officials say that the relationship between Russia, Iran and the Taliban goes beyond just diplomacy, and that conflict with the United States elsewhere could prompt Iran and Russia to raise the stakes here.

Afghan lawmakers have launched a probe into the alleged connections, including Iranian-Russian coordination to get weapons to insurgents in restive provinces in the south and the west.

Gul Ahmad Azami is an Afghan senator from Farah province, along the Iranian border. He says he was briefed on reports showing weapons that had transited into Farah from Iran, in part to ensure the allegiance of local commanders. Officials in Kabul, Helmand, Uruzgan, and Herat all made similar claims.

In Helmand province in the south, the provincial governor, Hayatullah Hayat, listed the type of weaponry he says local insurgents receive from Russia, with the help of Iran. The list includes land mines, sniper rifles, rocket-propelled grenades and 82mm mortar rounds.

"There is no doubt" the two countries are helping the Taliban, said Hayat, who was also briefed by intelligence officials.

He claimed Iranian advisers have been present on the battlefield, also citing intelligence reports and tribal elders in districts where there is fighting. The police chief in Uruzgan, Ghulam Farooq Sangari, also told the Voice of America's Afghan service that Russian advisers were assisting insurgents there, too.

Neither of those claims could be verified, and U.S. military officials have not said whether Iranian and Russian personnel have been on the ground. But the assertions speak to the extent to which the debate over Russian and Iranian influence has dominated Afghanistan in recent weeks.

"We are worried that Afghanistan will become another Syria, with world powers confronting each other here," Azami, the senator from Farah, said.

While President Donald Trump has taken a harsh stance on Iran, he has said little about what he envisions for the U.S. role in Afghanistan. Just this week, U.S.-Russian relations plummeted in the wake of U.S. strikes on a Syrian army base. The administration says it was used in an April 4 chemical weapons attack.

The state of U.S., Russian and Iranian relations will determine Afghanistan's stability, officials here say.

"First, people are concerned now about how Americans view Afghanistan, and whether or not they will change their minds about supporting us," said Mohammad Nateqi, an adviser at the office of Chief Executive Abdullah Abdullah. "The relationship between Afghanistan, the United States, and NATO has been very strong."

"But if there are bad relations between Iran, the United States, and Russia," Nateqi, who spent decades in Iran, said, "it will be very dangerous for us."