The Attorney General's Office said a police investigator and two prison guards who worked at a maximum security prison were among the victims.
Another five people were wounded during the attack in the town of San Luis Talpa near San Salvador, said national police director Rigoberto Pleites.
Pleites said witnesses told police the assailants were gang members dressed in uniforms similar to those issued to state road maintenance workers. But he said investigators haven't confirmed the attackers belonged to a gang.
In 2012, the Mara Salvatrucha and the rival Mara 18 street gangs agreed to a truce. Homicides dropped from 12 per day in 2011 to an average of 6.8 per day in 2013. But in the first three months of 2014, the homicide rate has spiked back up to about 8.9 killings per day.
Ramirez said officials have ordered that no police officers take time off in the coming days after at least 21 people were killed in the country in less than 24 hours.
The men's bodies were found half-buried in a clandestine grave in the town of Jaquilisco and members of the MS-13 gang are suspected in the killings, police said.
