The gunman accused of opening fire near a synagogue in eastern Germany on Wednesday has reportedly confessed to the deadly anti-Semitic crime -- and has told officials he also wanted to target mosques and kill Muslims, prosecutors said Friday.

The assailant, a German identified by prosecutors only as 27-year-old Stephan B., shot and killed two bystanders in the eastern city of Halle after failing to force his way into the local synagogue, which had up to 80 people inside celebrating Judaism’s holiest day, Yom Kippur.

GERMANY SYNAGOGUE SHOOTING THAT LEFT 2 DEAD ON YOM KIPPUR UNSETTLES JEWISH COMMUNITY

Flowers are set in front of the old synagogue in Essen, Germany, Thursday, Oct. 10, 2019. A heavily armed assailant ranting about Jews tried to force his way into a synagogue in Halle, Germany yesterday, before he killed two people nearby. (AP Photo/Martin Meissner)

Flowers are set in front of the old synagogue in Essen, Germany, Thursday, Oct. 10, 2019. A heavily armed assailant ranting about Jews tried to force his way into a synagogue in Halle, Germany yesterday, before he killed two people nearby. (AP Photo/Martin Meissner)

The spray of bullets killed a 40-year-old German woman in the street outside the synagogue and a 20-year-old man at a kebab shop nearby. The woman, prosecutors said, shouted at him as he tried to shoot his way into the synagogue.

Prosecutors said it was only the man's poor aim and the unreliability of his homemade firearms that saved nine other people – including a police officer – from injury during the half-hour rampage, Reuters reported.

He fled the city, wounding another two people in a small town near Halle where he abandoned his car and then stole a taxi. He was arrested about one and a half hours after the attack as he got out of the taxi, which had been involved in a crash.

The suspect live-streamed the attack on a popular gaming site while ranting in English about Jews and denying the Holocaust. He also posted a so-called "manifesto" online before committing the murders.

A person lies on a road in Halle, Germany, Wednesday, Oct. 9, 2019. A gunman fired several shots on Wednesday in German city of Halle and at least two got killed, according to local media FOCUS online. The gunman is on the run and police have sealed off the surrounding area. (Sebastian Willnow/dpa via AP)

A person lies on a road in Halle, Germany, Wednesday, Oct. 9, 2019. A gunman fired several shots on Wednesday in German city of Halle and at least two got killed, according to local media FOCUS online. The gunman is on the run and police have sealed off the surrounding area. (Sebastian Willnow/dpa via AP)

10 AMERICANS WERE IN GERMAN SYNANGOUE AS GUNMAN TRIED TO GET IN: AMBASSADOR

The 27-year-old claimed he "wanted to create a worldwide effect" by emulating attackers such as the man who killed 51 people in mosques in Christchurch, New Zealand in March and by encouraging others to imitate his own actions in Halle, prosecutors said Thursday.

Previously unknown to German authorities, he is being held on suspicion of two counts of murder, nine counts of attempted murder and several other offenses.

After the attack, bullet holes were clearly visible on the small wooden door of the synagogue – the only barrier between the gunman and the worshippers inside.

Bullet holes in the entrance door of a synagogue are pictured in Halle, Germany, Thursday, Oct. 10, 2019. (AP Photo/Jens Meyer)

Bullet holes in the entrance door of a synagogue are pictured in Halle, Germany, Thursday, Oct. 10, 2019. (AP Photo/Jens Meyer)

“We were actually just in the middle of Shacharit, which is the morning service, reading Torah, when I heard and saw explosions and two clouds of smoke right outside the window,” Christina Feist, who was inside the synagogue, told the BBC. “For a couple of seconds everyone was silent, and then all of sudden everything went super-fast. The cantor who was leading prayer immediately understood what was going on.”

She continued: “He said: ‘Everyone out of here – go to the next room, go upstairs, be on the floor, go down and go away from the windows.”

JEWISH LEADER WARNS CHRISTIANS AMID RISING ANTI-SEMITISM: THEY START WITH JEWS, BUT THEY NEVER END WITH JEWS'

Prosecutors said Stephan B. confessed to being inspired by right-wing extremism and anti-Semitism. They said Thursday that he had planned a “massacre” and had managed to amass at least nearly 9 pounds of explosives and four firearms.

A bullet hole is seen in a window of a kebab grill in Halle, Germany, Thursday, Oct. 10, 2019. (AP Photo/Jens Meyer)

A bullet hole is seen in a window of a kebab grill in Halle, Germany, Thursday, Oct. 10, 2019. (AP Photo/Jens Meyer)

The previous synagogue in Halle was set on fire as part of the Nazis' infamous 1938 Kristallnacht, or "Night of Broken Glass" anti-Jewish pogrom. German Interior Minister Horst Seehofer called Wednesday's attack "a disgrace for our whole country" after he visited the current house of worship on Thursday.

"With our history, something like this should not happen in Germany," Seehofer said. "Unfortunately, we must look the truth in the face, and the truth has been for a long time that the threat from anti-Semitism, right-wing extremism and right-wing terrorism in Germany is very high."

Unlike synagogues in many other German cities, the one in Halle didn't have police officers outside for Yom Kippur, a lapse that was criticized by Jewish leaders.

A person with a flag of Israel stands next to flowers and candles in front of a synagogue in Halle, Germany, Thursday, Oct. 10, 2019. (AP Photo/Jens Meyer)

A person with a flag of Israel stands next to flowers and candles in front of a synagogue in Halle, Germany, Thursday, Oct. 10, 2019. (AP Photo/Jens Meyer)

It and other synagogues in the region will now get full police protection.

CLICK HERE TO GET THE FOX NEWS APP

Germany's domestic intelligence agency says the number of anti-Semitic acts of violence rose to 48 last year, from 21 in 2017. It also said the number of far-right extremists rose by 100 to 24,100 people last year, with more than half of them considered potentially violent.

Germany's population of some 83 million includes about 200,000 Jews. Before the Nazis came to power, Germany had a Jewish population of about 500,000. Many of the Jews living in the country now are immigrants from the former Soviet Union who were taken in after the Berlin Wall fell in 1989.