The blast, which occurred in a building on Toledo Street, caused widespread damage, according to video footage tweeted out by the city hall emergency information service, Emergencias Madrid.
Images from the scene showed a section of exterior wall had been torn off several floors of the building, leaving rooms exposed to view. Debris covered parked vehicles and the street below, and a mangled metal street sign could be seen.
At least four floors have been impacted by the explosion and firefighters are evacuating people from the area, the service said.
The building could be at risk of collapse, Mayor José Luis Martínez Almeida told journalists. “Various people are being treated, (for injuries) of various severity,” he said.
Those killed were an 85-year-old woman and a man whose age was not immediately known, a spokesman for the emergency services told CNN. Two of those injured were taken to the hospital, one suffering from a broken ankle, he said.
No injuries were suffered either by senior citizens living at a care home next door to the building where the blast occurred or at a neighboring school, the spokesman said.
Martínez-Almeida urged caution as the authorities were still getting more details after the blast. “It seems there was a gas explosion,” he said.
The Archdiocese of Madrid said the building belonged to the Church of the Virgin de la Paloma and San Pedro el Real, which is next door, and had been “completely destroyed.”
“Two priests are in good condition and one has been transferred to a hospital. We are trying to find a person who was with them when the explosion happened,” the archdiocese said in a statement.
Police officers are at the scene, a spokesperson for Spanish National Police told CNN.
All residents from the elderly care home have been evacuated, said the director of Los Nogales residence, Antonio Berlanga.