Thushara Upuldeniya, spokesperson for the Prison Department, said an armed gang blocked the bus transporting the prisoners, who included an underworld figure.
"All five prisoners and two prison officers died. Nine other officers were admitted to hospital with injuries," Upuldeniya told Reuters.
Sri Lanka arrests army spies over editor's murder
Police spokesperson Priyantha Jayakody said investigations had already revealed that the attack was a result of a long-standing dispute between two gangs.
Suspects have been killed by gunmen in Sri Lanka in the past when being taken to court for questioning.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ