A Kurdish-led militia alliance says it has regained full control of a prison in north-eastern Syria seized by the Islamic State (IS) group six days ago.
A spokesman for the US-backed Syrian Democratic Forces (SDF) tweeted that "all Daesh terrorists" inside Hasaka's Ghwayran prison had surrendered.
Several hundred child detainees were also trapped in the facility with them.
At least 181 people have reportedly been killed in clashes since IS tried to stage a mass breakout on Thursday.
They include 124 militants and inmates and 50 police, SDF fighters and prison guards, according to the Syrian Observatory for Human Rights.
The UK-based monitoring group reported on Wednesday afternoon that the SDF was mostly in control of the prison, but it warned that militants might still be hiding in cells and sections that had not been searched.
The SDF is holding 12,000 men and teenage boys detained during the war against IS in overcrowded, makeshift prisons in northern and eastern areas of Syria under its control, as well as 60,000 women, girls and young boys in locked camps.
The attack on Ghwayran prison on Thursday night was the biggest IS operation since the jihadist group's military defeat in Syria in 2019 and came amid signs of a resurgence.
Sleeper cells used explosives to blow holes in the outer walls and enter the facility to free fellow jihadists among the estimated 4,000 male inmates.
Hundreds of SDF fighters and members of the allied Asayish security force battled to take back the prison with the help of fighter jets, helicopters and armoured vehicles from a US-led multinational coalition.
The SDF said 23 prison guards held as hostages had been freed and that more than 1,000 militants and inmates had surrendered before its spokesman Farhad Shami announced the end of the operation on Wednesday afternoon.
Mr Shami made no mention in his tweet of the 700 children who the SDF said had been used as human shields by the IS militants and inmates.
But he told Voice of America: "Had the safety of the children not been our major concern, we could have finished this operation in one to two days with heavy weapons."
The UN children's agency, Unicef, said on Tuesday night that it had received "deeply worrisome reports of fatalities among children" trapped in the facility and called on all parties to allow them to be evacuated to safety.
Some detainees had sent audio messages saying that they had seen the bodies of several children and warning that there was no food, water or medicine.
Letta Tayler of Human Rights Watch tweeted that she had been in contact with an 18-year-old American and a Canadian man inside the prison who told her that 15 to 20 boys could have been killed and that they feared they would be shot if they tried to leave.
"It's hard to guess honestly it's very chaotic," she quoted the Canadian as saying. "One kid I evacuated as we were trying to stop his bleeding, he died in front of me. His leg was busted open... We tried to stop the bleeding with a shirt. He looked very young."
Unicef said most of the 850 children, some as young as 12 years old, detained in prisons without charge by the SDF were being held at Ghwayran before Thursday's attack. Most were Syrian and Iraqi boys, while the rest are nationals of 20 other countries who refuse to repatriate them, it added.
The agency said the time had come for the children to finally be allowed to return to their home countries.
The SDF and the Kurdish-led administration in north-eastern Syria have also called for the repatriation of suspected jihadists and their families, warning that they do not have the resources to detain them forever.
The commander of the US-led coalition's joint task force, Maj Gen John Brennan, praised the "bravery and determination" of the SDF fighters in Hasaka.
But he warned: "This is not a problem solely within this city. This is a global problem that requires many nations to come together to develop an enduring long-term solution."
It is not clear how many inmates escaped during the prison attack. IS has claimed that it freed 800, while the SDF has said most of those who got away have been recaptured.