The killings happened yesterday in Quezaltepeque prison, north of the capital San Salvador, and were linked to an internal dispute involving the feared Barrio 18 gang, a spokesman for the presidency told AFP.
An official report into the bloodshed will be released in the coming hours, said Eugenio Chicas, the communications secretary for the presidency.
Prison officials were alerted when some members of the "Revolutionaries" faction of the gang failed to return to their cells, said Chicas.
"There has been an internal confrontation," said Chicas.
More From This Section
The Directorate General of Prisons, on Twitter, said it was "presumed to be an act of purification among gang members."
The deaths underline how gang violence has made El Salvador one of the most dangerous countries in the world.
On Wednesday, police said there were at least 125 murders in just three days in the country, a staggering toll even by El Salvador's standards.
"These are worrisome numbers. These are Salvadorans who are dying. Regardless of who is a gang member or not," National Police chief Mauricio Ramirez told reporters.
The gangs have some 72,000 members, including 13,000 behind bars.
Criminal gangs have been pressuring the government to include them in a commission examining ways to stem endemic urban violence for which these same groups are, to a large extent, responsible.
Since taking office last year, President Salvador Sanchez Ceren has tried to crack down on crime in the country and refused to negotiate with the gangs.
Last month, Barrio 18 ordered a bus strike and seven bus drivers were killed after they defied the gang.