The Pennsylvania man arrested for allegedly torching a Brooklyn rabbi’s home on Thursday had such a burning grudge against the religious leader that he tattooed a reminder on his forearm to “Never let go of the HATRED” and to “KILL” the rabbi.

Cops arrested Matthew Karelefsky, 41, of McKeesport, Pa., on Sunday and charged him with arson and two counts of attempted murder, for setting ablaze the Midwood home of Rabbi Jonathan Max early Thursday. The inferno leaped to two neighboring buildings and left 13 injured.

According to photos reviewed by The Post, the ink reads: “Never let go of the HATRED – KILL Rabbi Max YEMACH SHMO” — the final words a Hebrew phrase calling for the obliteration of the rabbi’s name.

In social media posts from 2018, a person named Matthew Karelefsky claims that the rabbi molested him.

“That’s nonsense,” Max told The Post on Sunday. “I have the man’s own explanation — it’s as crazy you would imagine.”

Karelefsky blamed the rabbi for the dissolution of his marriage in a 30,646-word “memoir” posted to Facebook in 2016.

Nowhere in the rambling account of his life — which includes personal details about how he first started to masturbate and once wished his own son would step in front of a bus — did Karelefsky level any molestation accusations against the rabbi, according to a copy of the screed obtained by The Post.

“Fundamentally he feels that I cheated him — that he thought so highly of me and I turned on [him],” Max said. “Somehow, he understood that I was a key figure — of which he was terribly mistaken. I was the one who told him not to divorce.”

Karelefsky and wife Inna divorced shortly after August 2010, according to the post, which was not accessible Sunday. In another portion of the screed, Karelefsky admits that he is “addicted” to “crisis/drama” and says he threatened suicide on Facebook for attention.

“To bring you many years ahead, in 2012 I purposely wrote on FaceBook that I was going to slit my wrists. I WANTED to be caught by the police and be brought to the mental hospital,” he wrote.

Karelefsky was awaiting arraignment in Brooklyn Criminal Court on Sunday.