The blast occurred at about 7 a.m. Thursday with more than 100 people inside Cuajimalpa Maternal Hospital -- minutes after a hose burst on a truck supplying gas to the building.
Rescuers rushed from the rubble with babies in their arms. Paramedics hauled bloodied victims on stretchers.
The truck operator was identified as Julio César Martínez and his two assistants as Carlos Chavez and Salvador Alatorre, according to Rodolfo Rios Garza, a local attorney. The charges against them were not immediately available.
Two of men in custody are hospitalized, and a third, with less serious injuries, was checked at a hospital.
Ivonne Lugo Durantes told CNNMexico
she spent 10 minutes trapped under rubble before rescuers reached her.
The supervising nurse called her husband, Mario Angeles Sanchez, after the blast. As she described what was happening, he heard people in the background screaming for help.
"I am still a little bit in shock. It was a nightmare," she said, describing how hospital workers tried to rescue babies from a nursery as flames engulfed the building.
A nurse and two babies were killed by the blast, Mexico City Health Secretary Armando Ahued told CNN affiliate FOROtv. At least 73 people were injured, he said, including about 20 newborns.
Outside the hospital, frantic family members searched for word of loved ones they feared were inside.
Searching continued Thursday evening at the site, though officials said it appeared everyone had been accounted for.
'She covered up the baby and ran'
Jose Eduardo was relieved to learn his wife and son, who was born Wednesday, had survived the blast. He heard about the explosion on the news from his home, where he'd gone to rest after the baby was born. He rushed to the hospital to be by his wife's side.
"She told me that it started to smell like gas and the ceiling started to fall on everyone," he told CNNMexico. "She covered up the baby and ran."
His wife was barefoot when she escaped, he said. Others were naked.
"We started pulling babies from the debris who were alive," Ignacio, a volunteer at the scene, told CNN. "We pulled out, fortunately, I think we pulled out seven. We would've wanted to pull out more."
Witnesses said the explosion shook the neighborhood.
"We heard something, and it smelled so much like gas, really a lot. And then two minutes, three seconds later, we saw an explosion that made everything fly in the air," witness Teresa Ramirez told CNNMexico
. "It threw me to the ground."
Virginia Gonzalez, who lives near the hospital, said her patio was covered with broken glass from blown-out windows.
After the explosion, Mexicans eager to help lined up at hospitals where victims were being treated, offering to donate blood and bringing bottled water and diapers for survivors.
Lugo, the nurse who was inside the hospital during the explosion, told CNNMexico she is suffering from first-degree burns but feels lucky to be alive.
"I feel grateful to have another chance to keep living," she said, "to keep working as a nurse."
Most of hospital has collapsed, mayor says
First, calls came into firefighters reporting a gas leak at the hospital, a facility on the southwest outskirts of Mexico City that is part of the government health system.
Hospital workers had already started evacuating the building when the explosion happened minutes later, Mexico City Mayor Miguel Angel Mancera told reporters.
One of the city's publicly accessible webcams captured the blast, showing a plume of smoke rising from the direction of the hospital.
A truck was supplying gas to the hospital when apparently a hose burst and the resulting leak caused an explosion, Mancera said.
The gas in question is known as liquefied petroleum gas, a mix that could be mostly propane or mostly butane. These propane/butane mixes are commonly used in Mexico for heating, cooking and other fuel applications.
Gas Express Nieto, the company that owned the truck, has operated in Mexico City since 2007 and has a contract to supply gas to hospitals run by the Mexico City government, the mayor said.
The hospital is 70% collapsed, Mancera said, although some walls and steel columns are still standing.