A boy rides a bicycle along a street in Deir al-Zor in eastern Syria on Feb.16. The writing on the wall reads in Arabic "The Islamic State in Iraq and the Levant.” (Khalil Ashawi/Reuters)

Radical fighters staged a strategic retreat from a key Syrian town on the Turkish border Friday amid growing tensions with rival rebel factions that threaten to erupt in a new war.

The retreat from Azaz of the Islamic State of Iraq and Syria ended a five-month reign of terror by the renegade al-Qaeda faction, which has used its position in the town to control access to Turkey and compromise supply routes for more moderate rebels.

The withdrawal could signal a new phase in the intra-rebel fighting that has pitted more moderate factions against extremists across northern Syria in the past two months, undermining the wider battle against forces loyal to President Bashar ­al-Assad.

The exit came a day ahead of a deadline issued by Jabhat ­al-Nusra, the official al-Qaeda affiliate in Syria, for ISIS to cease confronting rival rebels or face a new war. Commanders speculated that the ISIS fighters, who have resisted previous attempts at mediation, chose to pull out from Azaz to reinforce strongholds elsewhere in preparation for further conflict.

An activist in the town said ISIS fighters took their weapons, climbed into their vehicles and set off before dawn Friday, leaving residents to discover them gone when they awoke. A video posted on YouTube showed celebrations in the streets, with residents chanting “Free Syrian Army” as they thronged returning fighters from more moderate brigades who were driven out when ISIS took over the town in September.

Where the ISIS fighters went wasn’t immediately clear, but activists in Azaz said they had headed east, toward strongholds in the eastern part of Aleppo province and perhaps beyond to their self-styled capital of Raqqa.

The move continued a steady retrenchment by the extremists since an array of rebel groups launched an offensive against them across the rebel-held north in early January. ISIS has now been forced out of almost all of the province of Idlib and much of the province of Aleppo, leaving its fighters concentrated in the far east of the country.

Only Jabhat al-Nusra had held back from confronting ISIS, with which it shared ideological ties dating back to the formation of al-Qaeda’s Iraq branch. But since al-Qaeda’s leadership dissociated itself from ISIS last month, tensions have been growing between the two extremist groups, and this week’s ultimatum suggested that Jabhat al-Nusra may be gearing up to confront ISIS in its remaining eastern strongholds.

Azaz had been considered a key prize for ISIS, which has focused its efforts on capturing and controlling towns along the Turkish border since it began aggressively expanding into Syria from Iraq in the summer. Drawn from the Islamic State of Iraq, the original Iraqi al-Qaeda affiliate formed to fight U.S. troops, ISIS renamed itself to reflect its Syrian ambitions in April.

The presence of the extremists in the town had deterred humanitarian aid deliveries and also impeded supply routes for rebel units fighting the Assad the Assad government’s forces in Aleppo. Those routes may now open up, alleviating pressure on rebels elsewhere.

But the in-fighting has taken a heavy toll on the fight against Assad, leaving the rebels battling on two fronts and enabling a string of steady gains by regime forces around Aleppo, an important northern city. Recent gains by the government in suburbs north of the city, backed by a punishing campaign of barrel-bombings against residential ­areas, have left the rebel-held portion of the city in danger of being encircled.

“All the Aleppo fronts are falling apart due to this fighting, and the regime is advancing on most of them,” said an activist in Azaz who asked to be identified by his nom de guerre, Abu Mohammed al-Halabi, because he had cooperated with ISIS and now fears retribution. “People are scared on all sides because the military groups are fighting one another, and the victims are the people.”

ISIS’s harsh imposition of Islamic law in the places it controls has made it unpopular with many Syrians, contributing to widespread fighting against the group in January. Hours after the retreat from Azaz, rebels uncovered graves containing the remains of at least a half-dozen men who appeared to have been executed recently.

In one illustration of their use of brutal methods, ISIS fighters on Friday amputated the hand of a man accused of theft in the eastern Aleppo town of Maskanah. Pictures of the punishment were posted on Twitter, along with a statement proclaiming ISIS’s determination to enforce Islamic law. “This is what the Islamic State is trying to accomplish,” said one of the tweets.

Ahmed Ramadan contributed to this report.