A convoy of U.S. armored vehicles drives near a village on the western outskirts of the northern Syrian city of Manbij, on March 5. (Delil Souleiman/AFP/Getty Images)

The U.S. military is getting drawn into a deepening struggle for control over areas liberated from the Islamic State that risks prolonging American involvement in wars in Syria and Iraq long after the militants are defeated.

In their first diversion from the task of fighting the Islamic State since the U.S. military’s involvement began in 2014, U.S. troops dispatched to Syria have headed in recent days to the northern town of Manbij, 85 miles northwest of the extremists’ capital, Raqqa, to protect their Kurdish and Arab allies against a threatened assault by other U.S. allies in a Turkish-backed force.

Russian troops have also shown up in Manbij under a separate deal that was negotiated without the input of the United States, according to U.S. officials. Under the deal, Syrian troops are to be deployed in the area, also in some form of peacekeeping role, setting up what is effectively a scramble by the armies of four nations to carve up a collection of mostly empty villages in a remote corner of Syria.

The latest twist in Syria’s ever more complicated war points to one of the many risks of a U.S. strategy that has prioritized the military defeat of the Islamic State at the expense of political solutions to the broader conflicts fueling instability in the wider region, analysts say.

Photographs and videos posted on social media in recent days have shown convoys of U.S. troops, including Stryker armored vehicles and Humvees, heading through the northern Syrian countryside flying big Stars and Stripes flags. They have taken up positions in the villages north and west of Manbij, where U.S.-allied Arab forces backed by Kurds have been fighting for more than a week against U.S.-allied Arab forces backed by Turkey, according to U.S. and local officials.

The public display, unusual for a small U.S. presence of mostly Special Operations troops officially numbering just 503, is deliberate, a Pentagon spokesman, Capt. Jeff Davis, told reporters this week. “We want to have a visible show that we’re there,” he said, adding that the goal is to urge all parties to “stay focused on the common enemy, which is ISIS.”

Other wars are brewing elsewhere across the vast areas freed so far from Islamic State control, in Iraq as well as Syria. In recent days, the United States has been mediating between rival Kurdish factions in Iraq, both of them indirectly allied to the United States in the fight against the Islamic State, after clashes erupted around the northwestern town of Snune, freed from the Islamic State more than two years ago.

Manbij is the first instance, however, in which U.S. troops have become directly involved in keeping rival factions apart. The Pentagon has described their mission as one to “reassure and deter” local parties from attacking one another, a new role for the U.S. military in the Islamic State war, and one that could set a trend for the remaining cities to be conquered.

The deployment is “fraught with risk,” said Robert Ford, who served as the Obama administration’s last ambassador to Syria until 2014. He is now with the Washington-based Middle East Institute and teaches at Yale University.

“That’s not a small policy change. It is a huge policy change,” he said. “We have never in our Syrian policy ever put U.S. personnel in between warring Syrian factions or to maintain a local cease-fire.”

The deployment does not appear to signal a departure from the Obama administration’s policy of relying on Syrian Kurds and their Arab allies to fight the Islamic State in Syria, he said. The Trump administration has not announced the result of a review of the Obama administration’s policy for fighting the Islamic State, but U.S. officials have indicated that although it may involve more U.S. troops, it won’t diverge significantly from the original plan to rely on a force dominated by Syrian Kurds to continue the fight against the militants in Syria.

In pursuit of the plan, the Pentagon said Wednesday that U.S. Marines from the 11th Marine Expeditionary Unit have arrived in Syria to set up an artillery base, marking the first officially announced deployment of conventional U.S. troops in Syria.

The Manbij confusion does, however, point to the contradictions of a strategy that has focused on arming local factions to take on the Islamic State without regard to existing rivalries, said Aaron Stein of the Washington-based Atlantic Council. Military officials in Washington “are just laserlike focused on ISIS,” he said. “All this other stuff is on the back burner.”

The defeat of the Islamic State in Manbij last August offered an example of the complications likely to arise. Hailed as a significant military victory over the militants, the capture of Manbij cut the road between their capital in Raqqa and the Turkish border and paved the way for the ongoing, four-month-old offensive led by Kurdish forces to isolate Raqqa from the surrounding countryside.

It also, however, left the Kurdish People’s Protection Units, or YPG, in control of Manbij, in contravention of assurances the United States had offered to Turkey that the group would withdraw after the town was captured. Turkey objects to the YPG’s expanding presence in northern Syria because of its close ties to the Kurdistan Workers’ Party, or PKK, which has been waging a three-decade insurgency inside Turkey. Manbij’s strategic location west of the Euphrates River gave the Kurds a significant beachhead from which to advance the borders of the autonomous region they are creating in northern Syria.

Within weeks of the battle’s conclusion, Turkish troops crossed the border into Syria, with U.S. support, saying they wanted to join the fight against the Islamic State but also to push back against the Kurds. Advances by Turkish troops and their ­Syrian rebel allies culminated in the confrontations around Manbij over the past week between the U.S.-backed fighters on opposite sides of the Kurdish-Turkish divide.

The Manbij deployment has not yet affected U.S. plans for taking Raqqa, Davis said. But it does raise new questions about the viability of the U.S. plan to capture Raqqa, an overwhelmingly Arab city, by a force that is commanded mostly by Kurds.

To alleviate Turkish concerns about the U.S. relationship with the Syrian Kurds, the U.S. military has created a parallel, Arab force called the Syrian Democratic Forces that is allied with the Kurdish YPG but comprises recruits drawn from local Arab populations. U.S. Special Operations troops have now trained thousands of Arab recruits, who are expected to be put on the front lines of the eventual battle for Raqqa.

The SDF is also the force that negotiated the deal with Russia to have Syrian troops police the front line between the rival Manbij fighters — without U.S. input, according to U.S. officials.

That has fueled concerns among some of the Arab fighters recruited by the United States that their participation in the force will result in turning over areas they fight for back to the Syrian government, said Ahmed Mohammed of the Syrian Institute for Justice, who is from Manbij and has relatives in the city. Though SDF leaders owe loyalty to the Kurdish YPG, many rank-and-file fighters once belonged to the Syrian rebel groups that originally ousted the Syrian government from Manbij in the early years of the war, and they don’t want a deal that would bring the government back into the area, he said.

The fighters “have a lot of worry, but they don’t have any power,” he said. “It’s a big mess, and we are scared about the future of the people living in Manbij.”

Meanwhile, the U.S. presence in the area does not appear to have ended the fighting. Battles continued west of Manbij on Wednesday, according to both sides. A video posted on social media Wednesday morning showed U.S.-armed Arab fighters allied to the Kurds using an antitank missile to destroy a military vehicle belonging to the Arab fighters allied to Turkey. Though the provenance of the missile could not be ascertained, U.S. officials have confirmed that they began providing antitank missiles to the SDF late last year.

“This war is just so messy,” Stein said. “If we’re going to go into Syria and fight the Islamic State, we’re going to create a whole lot of wreckage. We’ve interjected ourselves into a multi­sided war.”

Correction: An earlier version of this story gave an incorrect first name for Pentagon spokesman Capt. Jeff Davis.

Missy Ryan and Karen DeYoung in Washington, Heba Habib in Stockholm and Zakaria Zakaria in Istanbul contributed to this report.