The country’s civil defence office said there are no immediate reports of damages or injuries from the quake that hit at 12.43pm local time (6.43pm GMT).
The US Geological Survey said the epicentre was about 95 miles south-southwest of the port of El Triunfo.
El Triunfo is located about 50 miles south-east of San Salvador, the capital.
Lina Pohl, the country’s environment minister, said there was a tsunami alert. She said that waves 6ft high might hit the coast.
A tsunami alert was also reported in Nicaragua, which was close to the epicentre.
Nicaragua was already under alert after category one hurricane Otto made landfall on the country’s Atlantic coast.