MAINZ, Germany — A man accused of killing two people in a shooting near a synagogue in the German city of Halle on Friday admitted to having “anti-Semitic and far-right extremist” motivations.

The German federal prosecutor’s office confirmed to NBC News that the suspect, named as Stephan B., gave a “comprehensive testimony” Thursday night, confessing to the Wednesday attack.

The prosecutor had earlier said the suspect had nearly 9 pounds of explosives in his car and had planned to carry out a "massacre."

The gunman failed to get into the synagogue, but went on to kill two bystanders in an attack that was live-streamed in a similar fashion to last year's gun attack on a New Zealand mosque.

Andy Eckardt reported from Mainz, Germany, and Nick Bailey from London.