BERLIN — A gunman killed two people outside a synagogue in the eastern German city of Halle on Wednesday, apparently filming his attack with a head-mounted camera in a method that had chilling echoes of a far-right attack on two New Zealand mosques earlier this year.

At the beginning of the ­35-minute video, a man in a green jacket that matches eyewitness accounts introduces himself as “Anon.” He denies the Holocaust and lists what he sees as the world’s problems, including immigration and feminism that leads to low birthrates.

“The root of all these problems is the Jew,” he says in the video, which was live-streamed on the gaming site Twitch and shared with The Washington Post by the International Center for the Study of Radicalization.

The man swears repeatedly and apologizes to his video audience as his plan appears to go awry, at points blaming his homemade weapons.

When a locked door keeps him from gaining entry to the synagogue packed with worshipers for Yom Kippur, he shoots a woman in the street and a man at a nearby kebab shop.

German authorities said they had one suspect in custody and were investigating a video.

A German security official, who spoke on the condition of anonymity to discuss an ongoing investigation, confirmed the gunman had recorded the attack on a head camera.

The official said that the suspect was a 27-year-old from Benndorf, Germany, who was not known to police or intelligence and that he was acting alone.

“This is definitely the same modus operandi as Christ­church,” the official said.

Brenton Tarrant, the 28-year-old white supremacist charged with shooting dead 51 people in Christchurch, New Zealand, in March, also recorded the attack on a head-mounted camera and live-streamed it.

But the Germany shooter lacked Tarrant’s firepower, limiting the fatalities.

The suspect in the Halle attack also appeared to have released an online manifesto, echoing another characteristic of recent right-wing extremist attacks, according to a copy shared by the ICSR. In the 11-page document — which researchers described as authentic — the author appeared to have laid out plans for his plot in advance but without revealing the synagogue’s location. In the document, the writer said, one of his aims was to “kill as many anti-Whites as possible, jews preferred.”

According to the manifesto, he initially considered attacking a mosque or a site associated with antifa, a militant leftist movement, but ultimately settled on a synagogue as his target.

Researchers consider the manifesto to be authentic because it includes specific details and photos of improvised weapons that appear to have been used in the attack.

Deadly synagogue attacks in Pittsburgh and in Poway, Calif., have rocked the Jewish community in the United States, while anti-Semitic hate crimes have risen significantly in Germany and other European countries.

Earlier this year, a German government official in charge of efforts to combat anti-Semitism sparked controversy when he said it might not be safe for Jews in Germany to wear traditional kippa skullcaps in public.

Wednesday’s attack drew quick condemnation. 

“We have to fight against anti-Semitism in our country,” tweeted German Foreign Minister Heiko Maas. “My thoughts are with the dead and injured, their relatives, and the police in these difficult hours.”

German Chancellor Angela Merkel attended a vigil in a Berlin synagogue Wednesday evening, her office said.

In a statement, Israeli Prime Minister Benjamin Netanyahu called the attack “another manifestation of the anti-Semitism in Europe.”

Twitch, the gaming site, said in a statement that it was “shocked and saddened by the tragedy” in Germany, adding that it had a “zero tolerance policy against hateful conduct.”

“We worked with urgency to remove this content and will permanently suspend any accounts found to be posting or reposting content of this abhorrent act,” the company said.

The company reported that a recording of the stream was viewed by about 2,200 people in the 30 minutes before the video was flagged and removed from the platform.

Twitch is owned by Amazon, whose chief executive, Jeff Bezos, owns The Washington Post.

The SITE Intelligence Group, which tracks online extremism, reported that white-supremacist communities online had applauded the attacker.

There were around 70 or 80 worshipers in the synagogue at the time of the attack, Max Privorozki, chairman of the local Jewish community, told Der Spiegel. He described watching via security cameras as a gunman attempted to enter the synagogue.

Synagogues in Germany are often guarded by armed police. 

In the video, the man arrives at the building to find the doors locked. He returns to his vehicle to retrieve what appears to be an improvised explosive device, but it fails to get him inside.

Giving up on the synagogue, he shoots a woman on the street, but his weapon misfires, as it does throughout the attack, when he attempts to shoot another person.

“Sorry, guys,” he tells his video audience as he drives off. “I tried to kill some,” he adds, trailing off.

He stops when he arrives at a kebab shop.

“All the customers next to me ran,” said a witness interviewed by German broadcaster N-tv. The witness said there were five or six people inside at the time. “I locked myself quietly in the bathroom. I wrote to my family that I love them,” he said.

In footage from inside the shop, the shooter again repeatedly misfires, but he hits one man.

By the time police arrive, about 15 minutes have passed since the man in the video approached the synagogue. Police shoot him, but he escapes and continues to drive.

“I’m a complete loser,” he says, before the video ends with him appearing to lie in the street for several minutes as vehicles drive by.

Germany’s federal prosecutor took over the investigation in a move spokeswoman Carolin Urban said “means that one can assume that this case is of relevance to the security of Germany.”

Before the video emerged, Urban told reporters, “Whether this case had an anti-Semitic motive still has to be determined. We do not exclude any possibility.”

The area was put on lockdown after the attack, with police initially reporting that multiple attackers had fled the scene. The security official said that as of Wednesday evening, police on the ground believed one perpetrator was more likely. 

Authorities urged those in the area to stay in their homes or office buildings, as all public transport was halted. Drago Bock, a spokesman for the city, said Halle had been on a state of “high alert” from early on. 

“All emergency services have been deployed,” he said. 

In the neighboring federal state of Saxony, authorities sent additional police units to protect synagogues, a spokesman confirmed. 

The U.S. ambassador to Germany, Richard Grenell, said 10 Americans were inside the synagogue at the time of the attack. “All are safe and unharmed,” he tweeted.

In Germany, there have been about 1,500 reported anti-Semitic verbal and violent attacks annually in recent years, but researchers say the actual figures are higher. One recent survey found that about 70 percent of anti-Semitic incidents go unreported, according to researchers at the Technical University of Berlin.

Morris reported from Warsaw. Souad Mekhennet in Washington contributed to this report.