Philippine police have killed at least 20 prisoners as they ended an uprising by Muslim militants at a maximum security prison near Manila.
Philippine police took control of the building floor by floor
Three prominent leaders of Muslim group Abu Sayyaf, involved in kidnapping and bombings, were among the dead.
The disturbance started on Monday when militants snatched weapons from guards, opening fire and killing three in an attempted escape.
On Tuesday, police stormed the building after a 15 minute ultimatum ran out.
Police said 22 prisoners and one policeman were killed during the operation, at Camp Bagong Diwa jail.
An Abu Sayyaf spokesman threatened to retaliate for the deaths, saying "we will bring the war to Manila".
Police named the Abu Sayyaf leaders killed as Galib Andang, alias Commander Robot, Alhamser Limbong, alias Commander Kosovo, and Nadzmie Sabtulah, alias Commander Global.
Galib Andang (Commander Robot)
On trial for kidnapping of 21 tourists on Malaysian resort of Sipadan in 2000
Alhamser Limbong (Commander Kosovo)
On trial for mass kidnapping of 2001-2 on Basilan and 2004 Manila ferry bombing which killed 100
Nadzmie Sabtulah (Commander Global)
On trial for Sipadan kidnap
Andang was captured in 2003. He allegedly led a group who kidnapped 21 Western tourists and local resort workers on the Malaysian island of Sipadan.
Limbong was on trial in connection with the bombing of a ferry in Manila Bay last year, which killed more than 100 people, as well as several abductions.
After Tuesday's assault, police escorted detainees from the prison, stripped to their underwear and with hands behind their heads. The police were greeted with applause from bystanders.
After the initial gun battle on Monday, in which three guards and two inmates were killed, a tense stand-off had ensued.
A deal later appeared to have been reached between the inmates and the authorities, with a Muslim politician acting as an intermediary with the rebels over the telephone.
But when the prisoners still had not given themselves up several hours later, the authorities gave the prisoners 15 minutes to lay down their arms.
After the ultimatum passed, police stormed the four-storey building at 0915 local time (0115 GMT) and started retaking it floor by floor.
Reports said some detainees could be seen climbing down the walls of the compound, as smoke billowed out.
The authorities describe the dead Abu Sayyaf leaders as the ringleaders of the revolt.
Interior Minister Angelo Reyes said security forces had decided to storm the compound "after considering all peaceful means".
He added: "They refused to yield the firearms which they grabbed from the guards and turned down our calls and assurances for their safety, including the plea of our Muslim leaders."
A Muslim member of parliament, who began negotiating with the inmates, said they had demanded timely trials, assurances of their own safety and the right to air their grievances to authorities and the media.
He said it was "saddening" the incident ended as it did.
"Even if they were criminals, they were still humans," he said.
Abu Sayyaf - which mainly engages in kidnap for ransom - is one of four Muslim rebel groups operating mostly in the southern Philippines.
It has been labelled a terrorist organisation by both Manila and Washington, and is believed by the US to have links with Osama Bin Laden's al-Qaeda network.
The Philippine government has deployed thousands of troops in the south in an effort to eradicate Abu Sayyaf.