Rioting was said to have begun at the Welikada prison in Colombo when police commandos arrived to provide security while prison guards searched for illegal items, the BBC reported Saturday.
A gunfight erupted after some prisoners seized weapons and guards fired on prisoners trying to escape.
At least three prisoners were killed as they fled the prison in a motorized rickshaw, witnesses said.
The bodies of 16 people were brought to the national hospital overnight, the hospital's director said. The bodies of another 11 inmates were still inside the prison, said the commissioner general of prisons.
Another 43 people were injured, five critically, the hospital director said.
The wounded included 23 prisoners, 13 police commandos, four soldiers and a member of the prison staff.
The prison holds about 4,000 prisoners.
Prison authorities said the situation at the prison was under control, but searches were under way for an undetermined number of prisoners who escaped. Six inmates have been captured.