At least 27 people were killed and a senior police officer seriously wounded in a gunfight in Sri Lanka's biggest prison that began when police came under fire from inmates, officials and police have said. 

The army brought the violence under control before dawn and freed staff held hostage at the Welikada prison in the capital Colombo, jail officials and military.

Twenty seven people have been confirmed dead, prisons minister Chandrasiri Gajadeera told parliament on Saturday.

The violence erupted when officers from the Special Task Force (STF), Sri Lanka's elite police commandoes, were searching the jail for drugs and illegal mobile phones.

"When they were coming out, prisoners started to attack them with stones. The STF used teargas and the prisoners fired at the STF," Police Spokesman Prishantha Jayakody said.

Witnesses said they saw police shooting towards the jail, where armed prisoners were on the roof during the clash.

Prisons Commissioner P W Kodippili told Reuters that the prisoners had obtained the weapons - some of them machine guns - by breaking into the prison armoury.

"The search operations are continuing to clear the place and recover the weapons and also to find the escapees," he said.

Army Spokesman Brigadier Ruwan Wanigasooriya said a large number of weapons were found along with six bodies during the search operation.

Contraband recovered

During the rioting, some of the convicts had tried to escape and were shot by security forces, witnesses said adding that tear gas too had been fired at rioting prisoners.

Some of the inmates got onto a roof and fired at troops and police on the ground. Police and troops fired back with intermittent gun fire heard for at least three hours, witnesses said.

Troops used armoured vehicles to move in reinforcements as inmates kept on firing, witnesses said.

Afghan, Indian and Pakistani inmates were also at the same jail, but none of them had been taken to hospital.

The identity of Friday's victims was not immediately clear, but witnesses said the dead appeared to be inmates.

A hospital source, however said, a jail guard was also among those killed.

"The STF search inside the prison went on for about five hours and they recovered a lot of contraband," a security official told the AFP news agency.

"As commandos were completing their raid, the inmates turned on them."

Power off

The standoff between rioting inmates and security personnel lasted several hours.

The convicts left the roof as the area plunged in darkness after the authorities switched off electricity.

 Deputy Inspector-General RM Ranawana, the commanding officer of the elite police force that had come under attack was in intensive care, the head of Colombo National hospital said.

"We've got 59 injured and 51 are still taking treatments and 16 are dead bodies," an official at the hospital told Reuters.

The jail has about 4,500 inmates, including members of the former defeated Tamil rebels from the Liberation Tigers of Tamil Eelam (LTTE) movement that fought a protracted war of independence, ending in 2009, but officials said it was unclear how many, if any, of them had been involved in the uprising.

There was similar violence at the same penitentiary in January when 25 inmates and four guards were wounded.

In 2010, more than 50 police and prison guards were wounded in a riot during another raid to seize illegal mobile phones.

Friday's violence was the worst riot at the maximum security Welikada jail since July 1983 when more than 50 ethnic Tamil prisoners were massacred by majority Sinhalese prisoners during anti-Tamil riots that had gripped the country.

Source: Agencies