The explosion appeared to be "gas-related," Mayor Bill de Blasio said, adding there were no reports of gas leaks beforehand.
The cause is under investigation.
Consolidated Edison inspectors were at the Second Avenue building "evaluating the meter installation for a new service ... to the building," utility President Craig Ivey told reporters. There was a second gas service in operation at the same building.
The installation of the new meter "did not pass our inspection at that time, so it meant it wasn't ready for gas to be introduced," Ivey said. Con Edison said in a statement that a survey Wednesday of gas mains on the block found no leaks.
Inspectors were at the building at 2 p.m. Thursday. The blast occurred at 3:17 p.m.
De Blasio said investigators were talking with the Con Edison employees who inspected the work of private contractors at the building. The name of the contractor was not provided.
"We are not going to speculate on details until we have a full report," the mayor said. "We have to put those pieces together."
The powerful explosion rocked a heavily traveled section the East Village in late afternoon, injuring some people with burns in their airways, scattering debris and forcing the closure of streets.
No one was believed to be trapped in the two collapsed buildings, officials said. At least two other neighboring buildings were damaged -- one in danger of collapse.
Images from the scene showed the first two floors of a five-story, red-brick building collapsed onto each other. That building and a neighboring one soon were leveled by the intense fire.
Luca Babini said he was in his office less than a block away at the time of the blast.
"Everything, my shelf in my office and my computer screen fell down," he said. "They say it was a gas leak."
Babini said a man immediately climbed a fire escape in an attempt to rescue people trapped in the collapsed building.
"I saw a lot of people lined up at the streets trying to help," he said.
Towering flames and plumes of black smoke at one point rose from the building where the fire started -- which includes both apartments and businesses. Emergency personnel could be seen taking the injured away on stretchers.
At least 250 firefighters responded.
The collapsed first floor housed a Japanese restaurant; the building next door, with a shop specializing in French fries on the street level, was ablaze and, in later images, appeared to have completely collapsed.
The explosion comes just over a year after two buildings in Harlem collapsed after a gas leak last March, killing eight people and injuring dozens. The buildings were served by a 127-year-old gas main.
After the 2014 incident, experts warned that many U.S. utilities were struggling to maintain or replace antiquated, hard-to-reach and leaky gas mains in older urban areas. The most vulnerable mains are made of cast iron or steel.
A day before the Harlem explosion, the New York-based Center for an Urban Future said in a report that New York's aging infrastructure "could wreak havoc on the city's economy and quality of life." An estimated $47.3 billion would have to be devoted for repairs to maintain safety.
The average age of New York City's 6,300 miles of gas mains is 56 years old, wrote the report's author, Adam Forman.