Alwaght-Seven were killed after gangsters ambushed a prison bus in the southwestern Sri Lankan town of Kalutara.
"All five prisoners and two prison officers died. Nine other officers were admitted to hospital with injuries,” media quoted Thushara Upuldeniya, a spokesman for the Prison Department, as saying on Monday.
He said one of the prisoners killed was a notorious figure in the criminal underworld, identifying him as Aruna Damith Udayanga, aka “Samayan".
The bus was headed from Kalutara prison to Kaduwela Magistrate Court when it came under fire in Kalutara by the gunmen, who were believed to be members of a criminal gang who were hostile to the notorious figure, officials said.
The attack was the result of a long-standing dispute between two gangs, said Police Spokesman Priyantha Jayakody after initial investigations.
He was a suspect in three murder cases and had been shot in an earlier incident in 2015 when he was being taken for questioning to the Kaduwela Magistrate Court. He had survived that shooting.
Crime suspects have been repeatedly targeted by gunmen in Sri Lanka in the past when being en route to courts.