The US Geological Survey said the quake hit at 0453 IST on the Pacific Coast 2 kilometres north-northeast of Puerto Madero, near the Guatemala border. It initially calculated the magnitude at 7.1 but later lowered the figure to 6.9.
Firefighters spokesman Raul Hernandez said at least two people died in their homes from collapsed walls in the Guatemalan town of Pati, in the border province of San Marcos.
The civil defence office in the Mexican state of Chiapas reported on its Twitter account that one man had been killed in Huixtla by a collapsed wall.
There were reports of power outages and rock slides on some roadways in Guatemala. Photos posted on social media sites and published by the Guatemalan newspaper Prensa Libre showed buildings with huge cracks across their facades in San Marcos, and one which apparently suffered a partial collapse.
In Chiapas, where the quake was centred, panicked people poured into the streets and the Red Cross said it was treating some frightened adults and children.
"I thought the house was going to collapse," said Claudia Gonzales, 32, who ran to the street in the town of Comitan with her 1-year-old daughter.
The quake was centred 60 kilometres below the surface.
In the city of Tapachula, near the epicentre, city employee Omar Santos said "buildings were moving, windows broke in some houses and businesses, and people ran through the streets in the dark.
