BEIRUT (AP) — Islamic State militants entered a major Syrian opposition stronghold in the country’s north on Saturday, clashing with rebels on the edges of the town as the extremist group builds on its most significant advance near the Turkish border in two years — even as it loses ground elsewhere in the country and in neighboring Iraq.

The town of Marea, just north of Aleppo city, has long been considered a bastion of relatively moderate Syrian revolutionary forces fighting to topple Assad. The IS assault underlined the weakness of the groups fighting under the loose banner of the so-called Free Syrian Army that have been struggling to survive.

More than 160,000 civilians have been trapped by the fighting, which also forced the evacuation of one of the few remaining hospitals in the area, run by the international medical organization Doctors Without Borders.

On Saturday, IS fighters staged two suicide bombings targeting “opposition forces” near Marea, IS said via its news agency, Aamaq.

Following the suicide bombings, IS militants entered Marea and fighting began inside the town, according to the Syrian Observatory for Human Rights, a Britain-based opposition media outfit that tracks Syria’s civil war.

Dr. Abdel Rahman Alhafez, who heads one of the last remaining hospitals in Marea, said the town was encircled and his hospital was under threat since Friday. “We need urgent protection for the hospital or a way out,” he said in an emailed statement.

Syrian army warplanes and helicopters, meanwhile, pounded other opposition-held towns in Aleppo province on Saturday, putting a further strain on embattled rebels fighting President Bashar Assad’s forces.

Islamic State’s territorial gains around Marea and Azaz, both critical rebel bastions north of the city of Aleppo, are a blow to the Turkey- and Saudi-backed opposition fighters who have been struggling to retain a foothold in the region while being squeezed by opponents from all sides. They also demonstrated the IS group’s ability to stage major offensives and capture new areas, despite a string of recent losses in Syria and Iraq.

American Special Operations forces and a coalition of Syrian and Arab fighters known as the Syria Democratic Forces have begun clearing areas north of Raqqa, the Islamic State’s de facto capital in Syria, in preparation for an eventual assault on the city.

The IS offensive targeting Syrian opposition strongholds near the Turkish border began on Thursday night.

On Friday, militants of the group captured six villages near Azaz, triggering intense fighting that trapped tens of thousands of civilians unable to flee to safety while Turkey’s border remains closed. A few hundred fled west to the Kurdish-held enclave of Afrin.

People are “terrified for their lives,” the International Rescue Committee said in a statement. The group said it has received confirmed reports that at least four entire families, including women and children, were killed Friday on the outskirts of Azaz.

The IRC runs centers for both children and women in Azaz and provides clean water and sanitation to a camp supporting 8,500 people. More than half the camp’s population has left to find safety elsewhere in the town, it said. The IRC also relocated its staff from the centers and the camp to safer areas of Azaz until the situation enables them to return.

The UN refugee agency said it was “deeply concerned” about the fighting affecting thousands of vulnerable civilians.

“Fleeing civilians are being caught in crossfire and are facing challenges to access medical services, food, water and safety,” it said in a statement Saturday.

The advances brought the militants to within a few kilometers of the rebel-held Azaz and cut off supplies to Marea further south.

World powers, including the United States and Russia which support opposing sides in Syria’s civil war, are at a loss as to how to jumpstart peace talks which collapsed in Geneva earlier this year. The war, now in its sixth year, has killed more than a quarter of a million people and displaced half the country’s population.

Azaz, which hosts tens of thousands of internally displaced people, lies north of Aleppo city, which has been divided between a rebel-held east and government-held west.

A route known as the Azaz corridor links rebel-held eastern Aleppo with Turkey. That has been a lifeline for the rebels since 2012, but a government offensive backed by Russian air power and regional militias earlier this year dislodged rebels from parts of Azaz, narrowing the corridor between the Turkish border and Aleppo.

The predominantly Kurdish Syrian Democratic Forces, who are fighting for their autonomy in the multilayered conflict, also gained ground against the rebels.

In recent months, Syrian rebel factions in Azaz — which include mainstream opposition fighters known as the Free Syrian Army along with some ultraconservative Islamic insurgent factions — have been squeezed between IS to the east and predominantly Kurdish forces to the west and south, while Turkey restricts the flow of goods and people through the border.

“With all these actors positioned to make land grabs in the area, and rebels exhausted by months of fighting, the corridor is now on the verge of collapse,” wrote Faysal Itani, a resident senior fellow with the Atlantic Council’s Rafik Hariri Center for the Middle East, in an analysis for the center.

He said the loss of the Azaz corridor would be detrimental for Turkey, which would no longer have proxy capability in northern Syria’s most strategic province, and complicate US efforts to fight IS in the area.

The Turkey-backed Syrian National Coalition opposition group appealed to world powers to provide urgent and immediate protection to civilians and arm rebels to counter attacks by IS and the Syrian government.

“By tightening the siege on the town of Marea, ISIS is following in the footsteps of the Assad regime which uses sieges of towns and cities as a weapon of war,” it said in a statement, using an alternative acronym for the Islamic State group.