U.S.-backed militias in Syria declared victory over Islamic State in its capital Raqqa on Tuesday, raising flags over the last jihadist footholds after a four-month battle.

The fighting was over and the alliance of Kurdish and Arab militias was clearing the city's stadium of mines and any remaining militants, said Rojda Felat, commander of the Raqqa campaign for the Syrian Democratic Forces (SDF).

A formal declaration of victory in Raqqa will soon be made, once the city has been cleared of mines and any possible Islamic State sleeper cells, said SDF spokesman Talal Selo.

The fall of Raqqa, where Islamic State staged euphoric parades after its string of lightning victories in 2014, is a potent symbol of the jihadist movement's collapsing fortunes.

Islamic State has lost much of its territory in Syria and Iraq this year, including its most prized possession, Mosul. In Syria, it has been forced back into a strip of the Euphrates valley and surrounding desert.

The SDF, backed by a U.S.-led international alliance, has been fighting since June to take the city which Islamic State used to plan attacks abroad.

A Reuters witness said militia fighters celebrated in the streets, chanting slogans from their vehicles.

The fighters and commanders clasped their arms round each other, smiling, in a battle-scarred landscape of rubble and ruined buildings around the main square.

The flags in the stadium and others waved in the city streets were of the SDF, its strongest militia the Kurdish YPG, and the YPG's female counterpart, the YPJ.

Fighters hauled down the black flag of Islamic State, the last still flying over the city, from the National Hospital near the stadium.

"We do still know there are still IEDs and booby traps in and amongst the areas that ISIS once held, so the SDF will continue to clear deliberately through areas," said Colonel Ryan Dillon, a spokesman for the coalition.

In a sign that the four-month battle for Raqqa had been in its last stages, Dillon said there were no coalition air strikes there on Monday.

TRAPPED BY FIGHTING

Fatima Hussein, a 58-year-old woman, sitting on a pavement smoking a cigarette said she had emerged from her house after being trapped for months by the fighting. Islamic State had killed her son for helping civilians leave the city, she said.

The fight for Raqqa has shattered much of the city. Houses, apartment blocks and public buildings were flattened by air strikes or holed by shellfire.

On Tuesday the international charity Save the Children said many of the 270,000 people who fled the fighting would likely be stuck in aid camps for months or years.

Children who fled were haunted by nightmares from the violence they witnessed, including Islamic State beheadings and coalition airstrikes, it said.

The SDF has said that after the Raqqa battle ends, it would hand over control to a civil council set up by its political allies. It echoes the pattern in other territory the YPG and its allies have taken across northern Syria.

Kurdish influence in the future of the mainly Arab city has been a sensitive issue for some activists from Raqqa and for Turkey. Ankara views the YPG militia as an extension of the PKK that has waged an insurgency on Turkish soil for three decades.

The SDF took the National Hospital after fierce fighting overnight and early on Tuesday, said spokesman Mostafa Bali.

"During these clashes, the National Hospital was liberated and cleared from the Daesh mercenaries, and 22 of these foreign mercenaries were killed there," said Bali, using the Arabic acronym for Islamic State.

An SDF field commander who gave his name as Ager Ozalp said three militiamen had been killed on Monday by mines that have become an Islamic State trademark in its urban battles.

Another field commander, who gave his name as Abjal al-Syriani, said SDF fighters had found burned weapons and documents in the stadium.

The stadium and hospital became the last major positions held by Islamic State after some of its fighters quit, leaving only foreign jihadists to mount a last stand.

The SDF has been supported by a U.S.-led international coalition with air strikes and special forces on the ground since it started the battle for Raqqa city in early June.

The final SDF assault began on Sunday after a group of Syrian jihadists evacuated the city under a deal with tribal elders, leaving only a hardcore of up to 300 fighters to defend the last positions.

PASSPORTS AND MONEY

Raqqa was the first big city Islamic State captured in early 2014, before its rapid series of victories in Iraq and Syria brought millions of people under the rule of its self-declared caliphate, which passed laws and issued passports and money.

It used the city as a planning and operations centre for its warfare in the Middle East and its string of attacks overseas, and for a time imprisoned Western hostages there before killing them in slickly produced films distributed online.

The SDF advance since Sunday also brought it control over the central city public square, where Islamic State once displayed the severed heads of its enemies, and which became one of its last lines of defence as the battle progressed.

The offensive has pushed Islamic State from most of northern Syria, while a rival offensive by the Syrian army, backed by Russia, Iran and Shi'ite militias, has driven the jihadists from the central desert.

On Tuesday, a military media unit run by Lebanon's Hezbollah said the Syrian army, which Hezbollah fights with, had pushed into the last Islamic State districts of Deir al-Zor city.

The only populated areas the jihadist group still controls in Syria are the towns and villages downstream of Deir al-Zor city along the Euphrates valley. They are areas that for the past three years Islamic State ran from Raqqa.