Two inmates were responsible for starting a riot at Darwin's notorious Don Dale Youth Detention Centre when they violently attacked a guard, stole his keys and released detainees from their cells.
A group of inmates then set the facility's school on fire, which was destroyed and grabbed angle grinders to cut fences and try to escape.
It took police more than seven hours to find all of the detainees after the emergency began at about 7pm on Tuesday. The fire also had to be put out.
All 25 inmates are currently in cells at the Darwin police station watch.
The Don Dale centre has been declared a crime scene and is not operational.
Flames and smoke were seen throughout the incident on Tuesday night as a public address system relayed a message to inmates.
"This is the police. Drop your weapons. Your actions are being monitored. There will be consequences."
Worried parents of some of the detainees drove to the centre after reading about the riot on social media.

A fire-damaged building at the Don Dale Detention centre in Darwin. Source: AAP
Two physically large inmates with cognitive problems, and described as "really, really challenging" by authorities, had allegedly attacked the guard.
It is the second time in three weeks keys have been stolen from a corrections officer at Don Dale.
One staff member suffered injuries including lacerations and stitches, Territory Families general manager of Youth Justice Brent Warren said.
'Broken adult prison'
He partly blamed the riot and a spate of violent incidents at the centre, that has been the subject of negative publicity this year, on the fact that it's a former adult prison not "fit for purpose" for rehabilitating young offenders.
"Territory Families inherited an adult prison that was retired a number of years ago," Mr Warren told reporters.
"We are trying to make do with what we've got, we have invested a significant amount of money changing the nature of the facility to make it look and feel more suitable for young people in detention.
"At the end of the day, it is still a retired and broken adult prison."
The former centre came under the national spotlight after the ABC aired footage of teenagers being tear-gassed, spit-hooded and shackled to restraint chairs - sparking a royal commission.
Earlier this year, the NT government accepted calls to close the centre after the commission uncovered disturbing evidence of abuse but a new centre is still at least several years away.
The final report of the $54 million inquiry released in November 2017 made 227 recommendations, all of which the government said it would adopt.