Several classrooms were destroyed from the blast at John F. Kennedy High School in Marble Hill. View Full Caption DNAinfo/Trevor Kapp

THE BRONX — A worker who lit a match to check if gas was coming out of a fuel line in a science classroom sparked the blast that destroyed part of a Bronx school Thursday night, officials suspect.

Construction workers were remodeling a science laboratory on the sixth floor of Marble Hill’s John F. Kennedy High School at about 8 p.m. when a powerful explosion destroyed parts of the fourth, fifth and sixth floors of the building, sending three workers to the hospital, one in serious condition.

Sources say the workers were supposed to shut off the gas to the lab at a source and then pump another less volatile but noxious fuel into the line, pushing the dangerous and odorless gas out the other end.

When the line is completely free of the odorless fuel, workers would normally smell the secondary fuel, which signals that the line is safe to work around.

But sources say a worker allegedly decided to test the line by striking a match near its tip — and it exploded with such force that a wall facing Terrace View Ave. was blown out onto the street.

"I do believe that this was a mistake," Mayor Bill de Blasio told 1010 WINS Friday afternoon. "It does not appear that was something that should have bee done."

It was not immediately clear if the workers failed to turn off the gas or if residual gas left in the line ignited.

“Residents felt a blast, they felt a building shake," de Blasio said during a press conference outside the building Thursday night.

"And what we see here at JFK High is a really shocking scene of the sixth floor having experienced a tremendous explosion."

Oscar Jimenez, 40, was working at Tibbett Diner nearby when the blast happened.

"I just heard an explosion. The restaurant was shaking for a second or two," Jimenez said. "It was scary. It just sounded like thunder coming from next door."

There are eight schools in the building and more than 4,000 students attend classes there.

Officials said they were unsure if the school will be ready to open at the start of the school year and several charter schools may need to find new homes.

Five rooms on the 7th floor of the building were also structurally damaged, Assemblyman Jeffrey Dinowitz said, and large pieces of the exterior wall on fifth, sixth and seventh floors were either damaged or destroyed.

Work was being done by a private contractor hired by the School’s Construction Authority, but the city did not immediately identify the company.

Ravi Shenoy with Shenoy Engineering applied in May to provide gas connections from the basement to the sixth floor science lab, according to Department of Buildings records.

Shenoy Engineering did not return a request for comment.

"I can say this is a contractor that School Construction worked with a lot in the past and had a good reputation," de Blasio said.