CAMBRIDGE, Massachusetts — A dozen Massachusetts firefighters were taken to the hospital for treatment of chemical burns early Wednesday they suffered while fighting a blaze in an apartment building, officials said.

The Cambridge firefighters arrived on the scene at just before 1 a.m. to find smoke on the fourth floor of the five-story building, according to the department.

When water was applied to a fire in a vacant unit, it reacted with chemicals, Assistant Fire Chief Thomas Cahill said at the scene.

The firefighters suffered “non-life threatening burns to their hands when the chemicals penetrated their firefighting gear.”

The chemicals were described as a “food grade peroxide and ammonia that combined creating the exothermic reaction.”

The firefighters were all later released from the hospital.

Four residents of the building were displaced. The cause of the fire remains under investigation.