A woman in Massachusetts has been charged with arson for allegedly setting her apartment building on fire, claiming it was "haunted" and the "devil made her do it."

Nikea Rivera, 45, allegedly lit her triple-decker in Boston on fire Tuesday morning, reported Boston 25. The two-alarm fire immediately spread from the first floor of the building through the three floors to the roof. Firefighters rushed to the apartment building to rescue the residents stuck inside as the wood-frame home went up in flames.

Two elderly men were rescued from the second floor using a ladder truck. One of them was transported to a local hospital for smoke inhalation. He is expected to recover. The other man didn't require immediate medical assistance.

"I'm sorry, I had to do it," Rivera told a witness, before walking away from the flames.

Boston Fire Department shared images of the partially damaged structure, with window glasses blown out and shattered.

Fire officials said they were able to douse the flames before noon. Rivera was taken into custody the same day.

"I had to do it. That house is haunted. I lit the house on fire," she reportedly told cops. "The devil made me do it, there are ghosts in my house."

A judge ordered her to undergo a mental health evaluation at the Worcester Recovery Center and Hospital.

"It's fortunate that this woman's actions did not result in any residents or responders being seriously injured or killed. Her statements are obviously disturbing and an immediate evaluation is the proper next step," said District Attorney Kevin Hayden, the NY Post reported.

The Red Cross provided assistance to the residents displaced by the fire. One woman said she had nowhere to go after the fire destroyed her home.

"I don't even know where I'm going to sleep at tonight," the woman, who didn't want to be named, told NBC Boston.

Firefighters
Firefighters use foam to battle a four alarm fire Jonathan Wiggs/The Boston Globe via Getty Images