BEIRUT — On the streets of Manbij, men chanted slogans against the Islamic State or clipped their beards and women walked with their faces uncovered for the first time in more than two years, hours after the militants were pushed out of the northern Syrian city.

U.S.-backed fighters seized the key Islamic State stronghold late Friday after two months of heavy fighting that killed more than 1,000 people and displaced thousands. The fighters also freed hundreds of civilians the extremists had used as human shields, Syrian Kurdish officials and an opposition activist group said.

The capture of Manbij is the biggest defeat for the Islamic State in Syria since July 2015, when they lost the town of Tal Abyad on the border with Turkey. The capture of Tal Abyad deprived the militants of a direct route to bring in new foreign fighters or supplies.

Manbij is important because it lies on a key supply route between the Turkish border and the city of Raqqa, the de facto capital of the Islamic State’s self-styled caliphate.

Manbij had been under its control since January 2014, when the extremists evicted other Syrian militant groups from the town.

Nasser Haj Mansour, of the predominantly Kurdish Syria Democratic Forces, said Manbij “is under full control,” adding that operations are ongoing to search for militants who might have stayed behind. The SDF launched its offensive in late May to capture Manbij, and was supported by U.S.-led airstrikes.

Amateur videos posted online showed that shortly after SDF fighters captured the town late Friday, scores of residents went down to celebrate in the streets. A man was filmed trimming his own beard with scissors, and then moving to clip the beard of another man on a motorbike. Women uncovered their faces.

The Islamic State imposes a harsh version of Islam on the territory under its control, including a mandatory dress code.

“May God destroy them. They slaughtered us,” a young man shouted in a Manbij square. “May they not live for a minute.”

In a photo posted online by Kurdish activists, a young woman defiantly uncovered her face while smoking a cigarette and flashing a victory sign.

Under the extremists’ rule, women had to wear long black cloaks that covered all but their eyes, while all adult men were forced to grow beards. Smoking was banned.

Haj Mansour said some Islamic State fighters were captured in the town while others fled to nearby villages. “Military operations will continue until these villages are clean,” he said.

Rami Abdurrahman, who heads the Syrian Observatory for Human Rights, a Britain-based monitoring group, said the remaining Islamic State fighters in Manbij left last Friday along with hundreds of civilians in some 500 vehicles heading for the city of Jarablus, on the border of Turkey.

The Observatory said that after the capture of Manbij, hundreds of civilians used as human shields by the Islamic State have been freed.

SDF fighters had been slowly advancing on the town and nearby villages for weeks.

According to the Observatory, the fighting and the airstrikes have killed 1,756 people, including 438 civilians, 299 SDF fighters and 1,019 militants since the Manbij offensive began in May.

Among those killed was the top Kurdish commander, known as Abu Layla, who died on June 5, days after sustaining wounds during the campaign.

The Islamic State has suffered major defeats over the past months in Syria and Iraq, where the military recaptured the cities of Ramadi and Fallujah in western Anbar province. However, the Islamic State still controls large parts of Syria as well as Iraq’s second-largest city, Mosul.