BEIRUT (AP) — Kurdish fighters backed by intense U.S.-led airstrikes pushed the Islamic State group almost entirely out of the Syrian town of Kobani on Monday, marking a major loss for extremists whose hopes for easy victory dissolved into a bloody, costly siege that seems close to ending in defeat.

Fighters raised a Kurdish flag on a hill in the border town near Turkey that once flew the Islamic State group’s black banner.

It represents a key conquest both for the embattled Kurds and the U.S.-led coalition, whose American coordinator had predicted that the Islamic State group would “impale itself” on Kobani.

The Britain-based Syrian Observatory for Human Rights and senior Kurdish official Idriss Nassan said the Islamic State group had been nearly expelled, with some sporadic fighting on the eastern edges of the town.

“The Islamic State is on the verge of defeat,” said Nassan, speaking from Turkey near the Syrian border. “Their defenses have collapsed and its fighters have fled.”

In September, Islamic State fighters began capturing some 300 Kurdish villages near Kobani and thrust into the town itself, occupying nearly half of it. Tens of thousands of refugees spilled across the border into Turkey.

By October, Islamic State control of Kobani was so widespread that it even made a propaganda video from the town featuring a captive British photojournalist, John Cantlie, to convey its message that Islamic State fighters had pushed deep inside despite U.S.-led airstrikes.

The town, whose capture would have given the jihadi group control of a border crossing with Turkey and open direct lines between its positions along the border, quickly became a centerpiece of the U.S.-led air campaign in Syria. U.S. Secretary of State John Kerry declared it would be “morally very difficult” not to help Kobani.

The U.S.-led air assault began Sept. 23, with Kobani the target of about a half-dozen airstrikes on average each day, and often more. More than 80 percent of all coalition airstrikes in Syria have been in or around the town. At one point in October, the U.S. air dropped bundles of weapons and medical supplies for Kurdish fighters — a first in the Syrian conflict.

Analysts, as well as Syrian and Kurdish activists, credit the air campaign and the arrival in October of heavily armed Kurdish peshmerga fighters from Iraq, who neutralized the Islamic State group’s artillery advantage, for bringing key areas of Kobani under Kurdish control.

Nassan said U.S.-led coalition strikes became more intense in the past few days, helping Kurdish fighters in their final push toward Islamic State group positions on the southern and eastern edges of the town.

The U.S. Central Command said Monday that it had carried out 17 airstrikes near Kobani over the last 24 hours that struck Islamic State group infrastructure and fighting positions.

Nassan said he was preparing to head into Kobani on Tuesday and expected the town to be fully free by then.

Gharib Hassou, a representative of Syria’s powerful Kurdish Democratic Union Party, or PYD, based in Southern Kurdistan, said fighting was still going in “two or three streets,” adding that most of the militants withdrew to the town of Tal Abyad to the east.

“There are a lot of dead bodies … and they left some of the weapons,” he said. Kurdish fighters also suffered high casualties, he said, adding that more reinforcements will be sent to reinforce control over the town.

Rami Abdurrahman, director of the Observatory, said the Kurdish force was led by Mohammed Barkhadan, the Kobani commander of the main Kurdish militia known as the People’s Protection Units, or YPG.

Barkhadan is a well-known militia leader among Kurds and in 2013 he led an offensive that ousted Islamic militants out of the northern Syrian town of Ras Ayn, Aburrahman said.

Since mid-September, the battle for Kobani has killed some 1,600 people, including 1,075 Islamic State group members, 459 Kurdish fighters and 32 civilians, the Observatory reported earlier this month. The Islamic State group, increasingly under pressure, has carried out more than 35 suicide attacks in Kobani in recent weeks, activists say.

Retired Marine Gen. John Allen, the U.S. envoy for the international coalition fighting the Islamic State group militants, in November predicted Kobani would be a defeat for the extremists.

The Islamic State group “has, in so many ways, impaled itself on Kobani,” he said in an interview in Ankara with the Turkish daily Milliyet.