At least 25 people were killed in Mexico's Oaxaca state, 17 of them in the town of Juchitán, officials said.

Another seven were reported killed in Chiapas and three more, including two children, died in Tabasco state. President Peña Nieto said more than 200 people had been injured.

At least one person was killed in Guatemala, its president has said.

Images showed collapsed buildings across Oaxaca. In Juchitán, the municipal palace and a number of other structures were destroyed or badly damaged.

Image copyrightEPAImage caption
Parts of the municipal palace in Juchitán were levelled

A hotel collapsed in the town of Matías Romero, Oaxaca state, but it is not clear if there were any casualties.

The Pacific Tsunami Warning Center (PTWC) had originally said that tsunami waves of more than 3m (9ft) were possible along the coasts of Mexico, with threats also facing El Salvador, Guatemala, Honduras and Costa Rica. It said later that waves only 0.7m high reached the Mexican coast.

Some coastal areas were evacuated as a precaution.

Panic on the streets

BBC's Lourdes Heredia

The earthquake has brought back memories of the tremor of 1985, which left massive destruction in Mexico City and a death toll of 10,000.

This explains the scenes of panic on the streets of the capital, more than 1,000km away from the epicentre. The government does not expect the same scale of physical destruction, as the states most affected are in the poorest and least-developed regions.

Chiapas is the southernmost state, along the Guatemalan border. It's a very mountainous, remote area, where 25% of the population belong to indigenous groups. It's also much visited by tourists seeking to explore some of the best and most well-preserved archaeological treasures, such as the ancient Mayan city of Palenque.

At magnitude 8.2, the quake outstrips the deadly 1985 tremor that hit close to Mexico City and caused thousands of deaths.

The US Geological Survey measured the latest quake slightly lower, at 8.1, saying it struck at a depth of 70km.

Image copyrightAFPImage caption
Soldiers stood guard after a hotel collapsed in the town of Matias Romero, Oaxaca state

Image copyrightReutersImage caption
The coastal town of Puerto Madero, Mexico, was among those evacuated amid fears of a tsunami

Image copyrightEPAImage caption
Damage in the Mexican city of Oaxaca, about 300km from the epicentre

Image copyrightAFPImage caption
The tremor was strong enough to bring down buildings near Mexico City

Mr Peña Nieto said the Salina Cruz refinery on the southern coast had temporarily suspended operations.

Schools were closed in 11 Mexican states.

Inevitable tremors

Jonathan Amos, BBC science correspondent

This is the biggest quake experienced anywhere in 2017. Going on the statistics, you would expect at least one magnitude 8 to occur somewhere on the planet each year.

It occurred where the Pacific ocean floor is drawn under Mexico and Guatemala. A great slab of rock, known as the Cocos tectonic plate, is driving towards the coast at a rate of 75mm per year. As it jerks downwards into the Earth's interior, about 200km offshore, large tremors are the inevitable outcome.

There have been three magnitude 7s in 2017, with a 7.9 recorded deep under Papua New Guinea back in January. This latest event, being an 8.2, is nearly three times as energetic. That tells you something about how the magnitude scale works.

Fortunately, this event was deep, too. The rupture, which will have ripped across more than 100km of fault line, was down at 70km. That will have limited some of the shaking, but as we've seen there is still extensive damage.

Some electricity cuts were reported in the capital and social media video showed lampposts and the famous Angel of Independence statue swaying violently.

Journalist Franc Contreras, who is in Mexico City, told the BBC: "You could hear loud cracks in the concrete. It sounded like a giant wooden branch being just broken open violently.

Image copyrightRed CrossImage caption
Guatemala's Red Cross tweeted damage in the town of Tacana, close to the Mexican border

"People were streaming out of the hallways here. And everybody walking out single file into the streets, trying to avoid overhead high power lines."

Guatemalan President Jimmy Morales appealed for calm on national television and in a Twitter post.

"We have reports of some damage and the death of one person, even though we still don't have exact details," Associated Press quoted Mr Morales as saying.

Cindy Lamothe, who is in the Guatemalan city of Antigua, told the BBC: "It was swaying so intensely it felt like we were in a boat and I heard neighbours screaming through the walls... it lasted almost three minutes."

Mexico is currently also being threatened on its eastern coast by Hurricane Katia.

The category one hurricane is about 300km south-east of Tampico and has sustained winds of 140km/h the National Hurricane Center says.