The man blamed for carrying out the attack was a 20-year-old “Islamist terrorist” who was released early from jail in December 2019.
Security has been tight in the Austrian capital as police launched a manhunt for further attackers.
But authorities believe the gunman shot dead by police may have acted alone.
Austrian Chancellor Sebastian Kurz said the four who died were an elderly woman, an elderly man, a young male passer-by and a waitress. Another 22 people were wounded.
One of the women who died was German, Germany’s Foreign Minister Heiko Maas tweeted, condemning the attack.
Interior Minister Karl Nehammer has not ruled out the possibility of a second attacker. Some witnesses spoke of seeing more than one gunman and police are still assessing some 20,000 mobile phone videos of what happened.
“Over 50% have already been watched but the assessment is not over. At the same time the videos already evaluated do not indicate that there was a second perpetrator,” the minister told reporters.
The attacks began at 20:00 local time (19:00 GMT) on Monday night, opposite the main synagogue in a pedestrian alley called Seitenstettengasse, and continued until the gunman was shot dead at 20:09.
Police identified a total of six crime scenes in the area, as witnesses described seeing attackers opening fire on people outside bars and then chasing them inside.
It was clearly an attack driven by “hatred of our way of life, our democracy”, Chancellor Kurz said.
A special service to commemorate the victims is being held at Vienna’s St Stephen’s Cathedral now, attended by Christian, Jewish and Muslim leaders and senior politicians including Chancellor Kurz.
Three days of national mourning have begun, with flags flying at half-mast. Children – those in Vienna kept at home for safety on Tuesday – will observe a minute’s silence at school on Wednesday.
Now the UK has raised its terrorism alert level to “severe”, from “substantial”, meaning an attack is highly likely, but no specific intelligence points to one.
It has also emerged that a police officer who was shot and wounded by the gunman was taken to safety by two men of Turkish descent.
“I took his legs, he took his shoulders, the police were there too of course and helped, and we quickly got him to the ambulance,” Mikail Özen, a personal trainer and mixed martial arts fighter, told journalists.
Mr Nehammer praised them, saying “more than ever: if people think that they can divide our society with violence, terror and fear it’s important to stand together”.
He said 14 people linked to the gunman had been detained. Most of the arrests were close to where he lived but two suspects were also arrested in St Pölten, to the west of Vienna, and one in the city of Linz.
What we know about the gunman
Earlier, Mr Nehammer described the dead gunman as an “Islamist terrorist”, who had been jailed for 22 months in April 2019 for trying to travel to Syria to join Islamic State (IS) jihadists.
The 20-year-old had been released early last December under more lenient terms for young adults. He had managed to convince the authorities that he no longer held extremist Islamist views, Mr Nehammer said.
Originally from North Macedonia, he had both Austrian and Macedonian citizenship.
Police have searched his home and seized video material. As well as being heavily armed, he was wearing a fake explosive belt, police said.
Mr Nehammer said the gunman opened fire with a sawn-off Kalashnikov assault rifle, but was also armed with a machete and a pistol.
The attack came hours before Austria imposed new national restrictions to try to stem rising cases of coronavirus. Many people were enjoying having a drink or eating out before a midnight curfew.
Elsewhere in Europe, France has suffered a spate of Islamist militant attacks recently, involving “lone wolf” jihadists.
Last month French history teacher Samuel Paty was beheaded outside a school in a suburb of Paris by a Chechen youth, who was then shot dead by police.
As the French government launched new measures to tackle militant Islam, a Tunisian man fatally stabbed three people in a cathedral in Nice.
The worst IS attack in Europe in recent years was in November 2015, when gunmen killed 130 people in Paris.
What reaction has there been?
European leaders strongly condemned the Vienna shooting. UK Prime Minister Boris Johnson said he was “deeply shocked by the terrible attacks” while German Chancellor Angela Merkel said “the fight against Islamist terrorism is our common struggle”.
French President Emmanuel Macron said Europe must not “give up” in the face of attacks. Last week he described the murder of three people in Nice as an “Islamist terrorist attack”.
Home Secretary Priti Patel said the UK would “stand ready to support in any way we can”.
US President Donald Trump – on the campaign trail ahead of Tuesday’s election – described it as “yet another vile act of terrorism in Europe”.
His Democratic challenger Joe Biden condemned the “horrific terrorist attack”, adding: “We must all stand united against hate and violence.”
Other Islamist terror attacks in Europe
Oct 2019: Radicalised police computer operator Mickaël Harpon is shot dead after stabbing to death three officers and a civilian worker at Paris police HQ
Mar 2019: Four people killed and two seriously wounded by gunman on a tram in the Dutch city of Utrecht
Aug 2017: A van attack is launched on pedestrians in Barcelona, and another attack in the Catalan coastal town of Cambrils. Sixteen people killed, more than 130 injured
May 2017: A bombing at a pop concert in Manchester, England, kills 22. Weeks later, eight people are killed and dozens injured in a van and knife attack in central London
Jul 2016: A gunman drives a large lorry into a crowd celebrating Bastille Day in Nice, killing 86 people – attack claimed by IS.