At least 27 people have died in clashes between inmates and guards at Sri Lanka's Welikada prison in the capital Colombo, authorities say.
The violence started when police commandos arrived at the prison to provide security whilst prison officers searched for illegal items.
After some prisoners seized arms a gunfight erupted. Witnesses said guards fired on prisoners who tried to escape.
Most of the casualties were inmates. Dozens were injured.
Prison authorities say the situation is now under control, but a government minister said a search for escaped prisoners was under way.
A police spokesman told the BBC six escaped prisoners have been recaptured, but said he did not know yet how many more remained on the run.
Prisoners' families and friends have gathered by the jail in a state of panic, the BBC's Charles Haviland reports from Colombo.
Up to 4,000 inmates are held in the jail, which has seen violence before.
The violence began when prisoners rounded on hundreds of police commandos who had entered the jail, the head of the prison service said.
The commandos used tear gas and prisoners broke into the armoury, seizing weapons and taking officials hostage.
A prison official told the BBC the commandos came to the jail without a court order and provoked the inmates.
However, prison officials also said the inmates opened fire first.
Guards killed at least three people when they fired on inmates fleeing from the prison in a motorised rickshaw, according to witnesses.
The director of the national hospital said the bodies of 16 people killed in the clashes were brought there overnight.
The commissioner-general of prisons told the BBC that bodies of 11 more victims - all inmates - were inside the Welikada jail.
Among 43 others injured were 23 prisoners, 13 police commandos, four soldiers and at least one member of prison staff, the hospital director said. Five were put in intensive care.
A prisoner who was in the jail at the time told the BBC Sinhala's Saroj Pathirana that clashes broke out when police commandos entered the jail, taking prisoners out of their cells and handcuffing them.
Some reports say the police may have been searching for drugs and smuggled mobile phones.
The prisoner told our correspondent that inmates seized weapons from the prison's weapon store during the confrontation.
Inmates were later seen waving rifles from the roof of a prison building.
The army was called in and surrounding roads were closed.
In January 25 prisoners and four guards were wounded when clashes erupted at Welikada, and in 2010 more than 50 police and prison guards were wounded during a raid to seize mobile phones.