(CNN) A man has confessed to an attack near a German synagogue in which two people died.
Named as Stephan B, the man appeared before an investigative judge at the Federal Court of Justice in Karlsruhe, Germany. Markus Schmitt, press officer of the prosecutor at the court, said: "Stephan B. has admitted to the accusations and specifically to his anti-Semitic as well as right-wing extremist motives."
A gunman killed two people in the German town of Halle, one directly outside a synagogue and one at a nearby kebab shop. The attack happened on Wednesday, Yom Kippur, the holiest day in the Jewish calendar.
Streaming live from a camera mounted on his helmet, he pushed on the doors of the synagogue, fired several shots at a lock on the door, stuck an explosive in a door jam and lit it but could not get in -- a fact that likely spared dozens of lives.
Watching it unfold on the synagogue's security cameras were 51 people barricaded inside, Max Privorozky, the head of Halle's Jewish community, told CNN.
The attack happened amid a rise in anti-Semitism in the country over recent years.
Data released by the interior ministry revealed that anti-Semitic hate crimes rose nearly 20% from 2017 to 2018, and the number of physical attacks against Jewish people increased from 37 in 2017 to 69 last year.
Earlier this year, German Jews were warned by a leading government official not to wear traditional kippahs in public, following a rise in attacks across the country.
A far-reaching CNN investigation into anti-Semitism across Europe last year also revealed that one in five survey respondents in Germany said Jews had too much influence in the media.
The country has also seen a surge in support for far-right parties like the Alternative for Germany (AfD), particularly in eastern states where the attack happened.
The anti-immigrant group has been widely criticized for using rhetoric reminiscent of Nazi Germany, with AfD politician Bjoern Hoecke previously calling Berlin's Holocaust memorial a "monument of shame," in comments reported by Reuters.