COLOMBO (Reuters) - 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 said on Saturday.

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 said.

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

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 machineguns - by breaking into the prison armory.

Slideshow ( 4 images )

“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.

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.

“We don’t know who is involved in this, I don’t think any LTTE suspects are involved but I don’t know,” Commissioner Kodippili told Reuters.

Kodippili also said the officials are taking the count of inmates to find out how many escaped.

“We don’t know exactly how many have escaped now we are taking the count,” Kodippili said.