Police have arrested a man in connection with a two-alarm fire at a Brooklyn synagogue Tuesday morning.

Police said Cesar Raynor, 71, was doing illegal torch work on the roof of the synagogue. The NYPD said he was one of several roofers hired to do work on the synagogue.

Flames broke out just after 9 a.m. inside the two-story B'nai Adath Kol Beth Yisrael, which is located on the corner of Patchen and Greene Avenues in Bedford-Stuyvesant.

The city fire department said the fire started on the roof and spread quickly, posing challenges to firefighters.

"In many of these houses of worship, there are voids throughout the structure, and once the fire gets into those voids, it's extremely difficult and challenging to fight that fire," said FDNY Deputy Chief Kevin Woods.

"So, the fire department moved in aggressively, with an aggressive interior attack, and due to the structural stability of this building, we had to pull members out and fight the fire with exterior streams."

Two firefighters were hurt trying to put out the blaze, but their injuries were not serious.

Crews were able to salvage scrolls and other articles, but Rabbi Baruch Yehudah said the predominantly African American congregation has lost a large part of its history.

"This was currently, in the city of New York, the oldest congregation in our community, and it housed most of our major communal events," Rabbi Yehudah said near the synagogue. "So, we're going to have to figure out what to do from here."

Raynor has been charged with Reckless Endangerment. He was released and will be back in court at a later date.

Wednesday night, some people were working to construct a fence around the synagogue to protect it.