Doctors and other health workers were evacuated from Oaxaca's Demetrio Mayoral Pardo General Hospital during the earthquake, Tuesday.
The National Seismological Service located the epicentre 23 kilometres (14 miles) south of Crucecita, Oaxaca, at 10:29 local time (17:36 GMT).
According to local reports, at least five people died from the quake. Meanwhile, the governor of Oaxaca, Alejandro Murat, reported that work is underway to quickly restore basic services interrupted by the earthquake.
The US National Oceanic and Atmospheric Administration (NOAA) issued a tsunami warning.