Video on social media showed buildings shaking in Mexico City. People in the city gathered on the streets as sirens blared.
Mexican President Enrique Peña Nieto said the National Civil Protection system protocols have been activated.
Mexico City's Civil Protection said no major damage was reported, but two people were killed after a military helicopter carrying Oaxaca Gov. Alejandro Murat crash landed while surveying damage. Murat escaped injury, but two people on the ground were killed, the governor tweeted early Saturday morning.
"My condolences and solidarity with the relatives of the people who unfortunately lost their lives in the wake of the unfortunate accident we suffered a few hours ago," Murat tweeted in Spanish.
The Mexico City Government wrote on Twitter, "Before returning to your homes, it is important to check if there are any damages, turn off gas lines and disconnect energy sources."
The quake was 15 miles deep, according to the U.S. Geological Survey. The National Seismological Service said 59 aftershocks had been detected before 6:30 p.m. local time.
Over 300 people, including schoolchildren, died from a powerful earthquake in central Mexico last September.