BEIRUT -- U.S.-backed Syrian forces celebrated in the devastated streets of Raqqa on Tuesday after gaining control of the northern city that once was the heart of the Islamic State's self-styled caliphate, dealing a major defeat to the extremist group that has seen its territory shrink ever smaller since summer.

Militants took over the vibrant metropolis on the Euphrates River in 2014, transforming it into the epicenter of their brutal rule, where opponents were beheaded and terror plots hatched.

It took thousands of bombs dropped by the U.S.-led coalition and more than four months of grueling house-to-house battles for the Syrian Democratic Forces to recapture Raqqa, marking a new chapter in the fight against the group whose once vast territory has been reduced to a handful of towns in Syria and Iraq.

"Liberating Raqqa is a triumph for humanity, especially women," who suffered the most under IS, said Ilham Ahmed, a senior member of the SDF political wing.

"It is a salvation for the will to live an honourable life. It is a defeat to the forces of darkness," said Ahmed, speaking to The Associated Press from Ein Issa, just north of Raqqa.

Fighters from the SDF celebrated by chanting and honking their horns as they spun doughnuts with their Humvees and armoured personnel carriers, and hoisting yellow SDF flags around Naim, or Paradise Square.

The infamous square was the site of public beheadings and other killings by the militants. Bodies and severed heads would be displayed there for days, mounted on posts and labeled with their alleged crimes, according to residents who later dubbed it "Hell Square."

Crumbled and flattened buildings stood behind the fighters as they drove around the square, a sign of the massive destruction the city has suffered since the militants took over. It was in Naim Square that the extremists paraded tanks and military hardware in 2014 in a chilling show of force that was a sign of things to come.

SDF commanders later visited Raqqa's sports stadium, which IS had turned into a notorious prison. Dozens of militants who refused to surrender made their last stand earlier Tuesday holed up inside.

"Immortal martyrs!" chanted the men and women in SDF uniforms, saluting their comrades who died battling for the city. According to the coalition, about 1,100 SDF forces have been killed fighting IS in Raqqa and Deir el-Zour.

"Military operations in Raqqa have ceased and we are now combing the city for sleeper cells and cleaning it from land mines," Brig. Gen. Talal Sillo told the AP earlier in the day.

A formal declaration that Raqqa has fallen would be made soon, once troops finish their clearing operations, Sillo said.

Col. Ryan Dillon, the Baghdad-based spokesman for the U.S.-led coalition, was more cautious, saying only that "more than 90 per cent" of Raqqa had been cleared. He estimated about 100 IS militants were still in the city and said he expects the SDF to encounter "pockets of resistance" during the clearing operations.

The battle of Raqqa has killed more than 1,000 civilians, many of them in coalition airstrikes in recent months, and displaced tens of thousands of people who face the prospect of returning to ruined homes. The coalition and residents who managed to escape accused the militants of using civilians as human shields and tried to stop them from leaving the city.

In a reminder of the humanitarian catastrophe unleashed by the fighting, the international charity group Save the Children said that camps housing tens of thousands of people who fled Raqqa are "bursting at the seams."

It said about 270,000 people from Raqqa are still in critical need of aid. With the high level of destruction reported in and around Raqqa, most families have nowhere to go and are likely to be in camps for months or years.

Ahmed, the SDF official, said the hardest part will be administering and rebuilding Raqqa. The group has appointed a civilian administration of locals to rebuild the city, but larger questions loom.

The SDF is a multi-ethnic force, but its Kurdish leadership harbours ambitions of autonomous rule over a Kurdish region in Syria that now includes the Arab-majority Raqqa, leading to concerns of a possible backlash among the city's Sunni Arab population.

Brett McGurk, the top U.S. presidential envoy to the anti-IS coalition, arrived in northern Syria and met Tuesday with members of the Raqqa Civil Council and members of the reconstruction committee.

He also met tribal leaders and urged them to work closely with the SDF, preventing the government of Syrian President Bashar Assad from using any divisions between them, according to the Furat FM, an activist-run news agency.

An immediate challenge was clearing Raqqa of thousands of land mines and booby traps that have killed returning civilians and senior SDF commanders in recent days. One of those killed Monday was the head of the internal security force affiliated with the SDF.

Another challenge for the troops is searching the tunnels that were dug by the militants around the city, Dillon said.

"This will take some time, to say that the city is completely clear," he told AP. "We still suspect that there are still (IS) fighters that are within the city in small pockets."

The loss of Raqqa will deprive the militants of a major hub for recruitment and planning, Dillon said, because the city attracted hundreds of foreign fighters and was a place where attacks in the Middle East and Europe were planned. The militants remain active in Syria, he said, farther south around the eastern province of Deir el-Zour.

In recent months, the Islamic State has steadily lost ground in Iraq and Syria, including Iraq's second-largest city of Mosul. It has also lost major territory to Syrian government forces who have been marching against the group in a simultaneous but separate offensive, mainly in Deir el-Zour province.

Syria's state news agency said government forces and their Russian and Iranian-backed allies captured the Deir el-Zour villages of Mouhassan, Bouomar and Bouleil that were once extremist strongholds.

The Britain-based Syrian Observatory for Human Rights also reported that government forces now control more than 90 per cent of the city of Deir el-Zour, where a major offensive is underway to capture remaining IS-held neighbourhoods.

The battle for Raqqa began in June and the SDF met with stiff resistance from the militants. It began its final assault on Sunday after nearly 300 IS fighters surrendered. Naim Square was captured Monday.

The force seized the hospital Tuesday, taking down the last black IS flag, according to the Kurdish-run Hawar news agency. A video from Hawar showed the clashes around the hospital, which appeared riddled with bullets and partly blackened from a fire.