The man who police say set a Brooklyn rabbi’s house on fire amid a long-held grudge over alleged abuse he says he suffered as a child was caught on video sparking the blaze, prosecutors revealed Monday.

The detail emerged as Matthew Karelefsky pleaded not guilty to attempted murder and arson charges before Brooklyn Supreme Court Justice Martin Murphy on a 17-count indictment.

The 41-year-old Pennsylvania man, whose arm is inked with a tattoo reminding him to “kill” Rabbi Jonathan Max, was ordered held without bail following his arraignment on charges of first-degree attempted murder, second-degree arson, second-degree attempted murder and other counts.

Prosecutors said Karelefsky was caught on surveillance footage setting the blaze, and was also captured on video a day earlier buying Kingsford charcoal that was used in the fire.

Authorities said an investigation has determined the fire began under the rabbi’s front porch, where K9 units identified the scent of an accelerant. Fire marshals also recovered the charred remnants of a Kingsford charcoal bag, charcoal, a plastic milk carton, empty lighter fluid containers, lighter boxes and several pieces of cloth.

Karelefsky was arrested June 15, and previously told The Post he hates the rabbi because he allegedly sexually abused him as a teen, and admitted to setting the fire.

Max has wholeheartedly denied that allegation, saying the alleged firebug dislikes him because he sided with Karelefsky’s ex-wife during a 2012 divorce proceeding.

He’s due back in court on Sept. 10, and faces up to life in prison if convicted.