VIENNA — Peering out a window at Vienna's main synagogue compound Monday night, Rabbi Schlomo Hofmeister watched as a gunman opened fire on customers sitting outside bars and restaurants of the city's central nightlife district.

The shots rang out — dozens of volleys, perhaps hundreds; he isn't sure — sending people fleeing through the streets in panic and into bars to seek cover. The attacker followed them inside, Hofmeister said. More gunfire followed.

The shooting left at least five dead, including an assailant, and 22 people wounded.

The slain suspect was identified as Kujtim Fejzulai, 20, a joint Austrian and North Macedonian citizen who had been sentenced to 22 months in detention for trying to join the Islamic State but had been released from prison early.

The militant group on Tuesday claimed credit for the attack.

The shooting came amid an uptick in extremist violence in Europe, with four people killed in knife attacks in France over the past month. Britain on Tuesday raised its terror threat to "severe" as a "precautionary measure."

Terrorist attacks in Austria, however, have been extremely rare. The last major incident was in 1985, at the Vienna airport.

Monday's shooting unfolded as the city's residents relished a few final hours of revelry before a new coronavirus lockdown. Armed with an assault rifle, machete and fake suicide belt, Fejzulai spread mayhem for nine minutes until he was killed, officials said. In the initial chaos, police reported that there were multiple attackers, but security officials backpedaled Tuesday, saying that the videos examined so far — among tens of thousands submitted by the public — indicated a single shooter.

"It was an attack motivated by hate — hate for our core values, hate for our way of life, hate for our democracy in which all people are equal in rights and dignity," Austrian Chancellor Sebastian Kurz said in a morning news conference. "But it's clear that we will not be intimidated by the terrorists. It is a battle between civilization and barbarism, and we will fight this battle with all determination."

Authorities carried out house searches in the wake of the attack and made 14 preliminarily arrests.

The Islamic State described Fejzulai as a "soldier of the caliphate" in a statement released by the group's Amaq News Agency on Tuesday evening. It named him by the nom de guerre Abu Dujana al-Albani. Earlier, Islamist militant forums circulated an image they claimed to be of Fejzulai, said Rajan Basra, a researcher at the International Centre for the Study of Radicalisation at King's College London. The picture showed a bearded man holding a large knife, a pistol and a Kalashnikov-style rifle. It was accompanied by a pledge to Islamic State leader Abu Ibrahim al-Hashimi al-Qurashi.

Interior Minister Karl Nehammer said the attack, coming after Fejzulai's early release from prison, pointed to "gaps" in the country's deradicalization efforts. The suspect had "fooled" the system, he said.

"This is obviously going to raise huge questions in Austria about why he was released early," said Basra, who specializes in researching Islamist militants within criminal justice systems.

Fejzulai was sentenced in April 2019, but was released by December that year.

He had set out to Syria in September 2018, according to news coverage of his trial. He made it to an Islamic State safe house in Turkey, but was detained there and spent four months in a Turkish jail. He and a co-defendant said they'd been ready to fight with the Islamic State, but a defense lawyer argued that they had renounced the group.

Fejzulai explained his radicalization by saying he'd gone to the "wrong mosque," according to Austria's Der Standard newspaper at the time.

Countries across Europe saw citizens leave to fight alongside the Islamic State at the height of its self-declared caliphate. And, since then, countries have struggled with how to repatriate and reintegrate those citizens.

"Every country around Europe is facing that same issue," Basra said, noting that individuals have convinced experts that they have reformed, or were taken advantage of, and pose less of a threat than they do.

Austrian security officials said the whole system needed to be evaluated. There is never "absolute certainty" that a person has been correctly assessed, said police president Gerhard Pürstl.

The gunfire began around 8 p.m. Monday in Vienna's "Bermuda Triangle," an area of the city known for bars where one can disappear during a night of heavy drinking.

Hofmeister said he saw at least one attacker who seemed "professional."

“He wasn’t shooting around randomly. It was very targeted and coordinated,” the rabbi said.

Early reports that the synagogue may have been attacked brought back memories of 1981, when Palestinian militants armed with automatic weapons and grenades killed two people during a bar mitzvah service.

But Hofmeister said there was no indication that the synagogue was a target on Monday. The building was closed at the time, and there was no activity inside, whereas the streets outside in the Innere Stadt neighborhood were busy.

“We are here in a popular nightlife district, the nightlife district of the city,” he said. “It was a very warm evening, so a lot of people were out, and it was the evening before the lockdown.”

As midnight approached, though Fejzulai had been killed, authorities said the situation remained active. Heavily armed officers swarmed the capital, blocking roads and searching vehicles. Medics set up a triage area to treat the wounded. Police urged residents to stay inside during the manhunt — and to stay home from work and school if possible Tuesday.

According to an initial law enforcement assessment, the shooting took place at six locations. But authorities said assessments were still being made and more details would be released later.

An elderly man, an elderly woman, a young passerby and a waitress were killed “in cold blood,” Kurz said. The wounded included a police officer who stepped between civilians and a gunman, he said. That officer was in stable condition Tuesday after surgery.

Sara, a 20-year-old Albanian who moved to Vienna a year ago, was drinking coffee nearby when she heard shots. “We saw the panic. We saw a girl, she was running, she was injured. She was crying,” said Sara, who did not want to give her last name with attackers still potentially on the loose.

Before Monday night, she thought Vienna was the “safest city in the world,” she said. “We never expected this to happen. I don’t know how we are going back to our normal lives after this.”

Barbara Lovett, a 52-year-old opera singer manager, was watching a three-hour performance at the city’s opera house when the shooting started a half-mile away. It was only when she turned to her phone at 10 p.m., when the performance ended, that she realized what was happening. Police held the audience in the building.

Members of the orchestra began to play as they waited to be allowed to go home. “This is Vienna,” Lovett said, referencing a city famed for its opera and for producing classical composers such as Mozart, Strauss and Schubert. “We have to play music. That’s what we know.”

Morris and Beck reported from Berlin.