The Islamic State group launched a counterattack against rebel fighters trying to capture the Syrian city of Manbij on Monday, inflicting heavy casualties on the U.S.-supported forces, the Syrian Observatory for Human Rights and the militants said.

The monitoring group said the extremists also known as ISIS won back three villages south of the besieged city in a surprise assault against fighters from the U.S.-backed Syria Democratic Forces. At least 28 SDF fighters were killed.

Two years after ISIS proclaimed its caliphate to rule over all Muslims from territory it seized in Iraq and Syria, its many foes are advancing on a number of fronts in both countries. Their aim is to close in on its two capitals, Raqqa in Syria and Mosul in Iraq.

The SDF were poised to enter Manbij nearly three weeks after the launch of a major assault to regain the city that was backed by U.S. air power and American special forces, to seal off the last stretch of the Syrian-Turkish frontier under ISIS control.

The alliance, formed last year by recruiting Arabs to join forces with a powerful Kurdish militia, fought to nearly 2 km (1.24 miles) from the city center from the western side on Saturday before retreating.

U.S-led coalition jets hit Islamic State militants taking cover near a large wheat silo complex on the southern edge of the city that has been encircled by SDF forces.

An SDF spokesman said forces succeeded in repulsing the militant attack and remained positioned on the outskirts of the city, most of whose residents remain trapped inside due to mines planted by the militants, who have dug in to defend it.

"The situation is under control. They have many bodies on the ground," Sharfan Darwish, spokesman for the Syria Democratic Forces-allied Manbij Military Council, told Reuters.

"We are at the four gates to the city. The whole city is booby-trapped. After 20 days of the campaign, we have yet to storm the city," he added, adding that some 2,000 people had succeeded in fleeing the city.

Islamic State militants were also able to roll back the Syrian army, which had reached as close as 10 km (6.2 miles) south of the strategic town of Tabqa, an Islamic State-held city on the Euphrates River, in Raqqa province.

The town, some 50 km (30 miles) west of Raqqa city, the militant's de facto capital, appears to be the first target of a major Syrian army assault in Raqqa province backed by Russian air power that began earlier this month. 

The Tabqa dam and a major air base have been in ISIS hands since 2014.

The monitor said the Syrian regime army's setbacks on Sunday lost it territory gained over weeks of advances which enabled it to enter Raqqa province for the first time in more than two years.

Amaq news agency, which is affiliated with ISIS, said suicide bombers had attacked the Thawra oil field, south of Tabqa, which the Syrian army had captured earlier this week, and regained it.

Eyad al Hosain, a Syrian journalist embedded with Syrian government troops, told Reuters the militants had succeeded in regaining areas they lost near the oil field. He did not give figures on army casualties.

"A very intense attack has targeted army and allied positions in Thwara field that led to the withdrawal of troops from areas they liberated ... and their retreat," al Hosain said.

Amaq also said militants seized a Syrian army checkpoint near a strategic junction that leads to Raqqa city that the government forces and their allies had seized in the early phase of its Raqqa campaign.

The monitor, which tracks violence across the country, said the militants had sent reinforcements and cited at least 300 fighters heading to Tabqa from Raqqa.

State media also reported clashes with the militants around the main Jazal field near the ancient city of Palmyra in the country's central desert. The army and its allies continue to fight a costly war of attrition against Islamic State militants several months after seizing the city from them.