A hate-filled gunman accused of killing two people on Yom Kippur near a German synagogue was inspired by the massacre at a New Zealand mosque in March and livesteamed his attack to incite more copycats, prosecutors said Thursday.

Stephan Balliet, 27, arrived at German federal court via police helicopter in a white prison jumpsuit, handcuffs and shackles on his legs after he allegedly went on a murderous spree in the eastern city of Halle on Wednesday.

Federal prosecutors said Balliet wanted to commit a “massacre” and kill as many people as possible in the Judische Germeinde Halle temple as worshipers gathered on the holiest day on the Jewish calendar, Reuters reported.

“What we experienced yesterday was terrorism,” federal prosecutor Peter Frank told reporters. “According to our findings, the suspect Stephan B. aimed to carry out a massacre.”

Frank said Balliet was motivated by “scary anti-Semitism, xenophobia and racism” and had armed himself with 8 pounds of explosives.

“He armed himself with many weapons, some possibly self-made, and had a large quantity of explosives,” Frank said, adding Balliet said he was inspired by the attack in Christchurch, New Zealand, which killed 51.

“Stephan B. wanted to be copycat in two senses,” he added. “He wanted to mimic similar acts that happened in the past, and he also wanted to incite others to copycat his acts.”

The gunman livestreamed his deadly rampage on Amazon-owned video platform Twitch, but was foiled by his homemade improvised firearms, which repeatedly jammed, the Guardian reported.

Footage of the attack showed the suspect unsuccessfully trying to shoot open the door of the synagogue around midday as 80 terrified worshipers, including 10 Americans, huddled inside.

Frustrated, Balliet called himself a “loser” in the video and at one point said: “I have certainly managed to prove how absurd improvised weapons are.”

After fatally shooting one female passerby outside the synagogue, the suspect drove to a nearby kebab joint, where he opened fire and killed another man.

In a screed published on a German message board, the gunman said he deliberately chose a synagogue on Yom Kippur — but had also considered attacking a mosque, according to the Guardian report.

Members of the German Jewish community criticized police for not being stationed outside the synagogue on the holy day.

“It is scandalous that the synagogue in Halle was not protected by police on a holy day like Yom Kippur,” said Josef Schuster, head of Germany’s Central Council of Jews.

But the head of Germany’s police union said it was an impossible task to keep every house of worship safe.

“We’d have to guard every synagogue, every church, every mosque, every holy place in Germany around the clock, so I don’t know if this was a mistake or if this really couldn’t have been foreseen,” Oliver Malchow told ARD public television, Reuters reported.