The Strasbourg gunman yelled “Allahu Akbar” (“God is greatest” in Arabic) as he opened fire on people enjoying an evening out at a Christmas market, the Paris public prosecutor told reporters.
Rémy Heitz said two people had been killed and one left brain-dead after the attack in the eastern French city on Tuesday.
Twelve were wounded, six seriously.
The man, named by local media as Chérif Chekatt, was known to authorities as having been radicalised in prison.
The 29-year-old was armed with a gun and a knife and escaped the area in a taxi, Mr Heitz said.
The attacker boasted to the driver – who has spoken to police – that he had killed 10 people, and said he had been injured in a firefight with soldiers.
Four people connected to the suspect had been detained overnight in Strasbourg, Mr Heitz added. Sources close to the investigation quoted by Reuters news agency said they were the suspect’s mother, father and two brothers.
Hundreds of officers are currently involved in the search for the gunman. France’s Deputy Interior Minister Laurent Nuñez earlier acknowledged he may no longer be in France.
Interior Minister Christophe Castaner said the country had moved to a high level of alert, expanding police powers and increasing vigilance.
He added that border controls had been strengthened and security at all Christmas markets would be stepped up.
The mayor of Strasbourg, Roland Ries, has said the Christmas market will be closed on Wednesday and flags lowered to half-mast at the local town hall.
The attack unfolded at around 20:00 local time (19:00 GMT) on Tuesday close to Strasbourg’s famed Christmas market near one of the central squares, Place Kléber, which attracts thousands of visitors at this time of year.
A woman called Audrey told France’s BFM TV how she came face to face with the killer after watching him shoot a man in the head.
The gunman then opened fire for a second time, and another man fell to ground.
Her friends began to run to safety, but Audrey was frozen to the spot. The gunman turned, and faced her – but then he too ran.
“Why didn’t he shoot at me?” she told the TV channel. “I don’t know. I think I was extremely lucky. As everyone was screaming he fled.”
According to Mr Heitz, as he fled he came into contact with four soldiers. He began firing at them and they fired back, apparently injuring him.
How did he escape?
He managed to reach a taxi which drove him away from the scene and dropped him in the vicinity of the police station in Neudorf, the area where he lives which sits on the border between Germany and France.
When he got out the vehicle, he fired at police officers.
What do we know about the gunman?
According to police – who refer to him as Chérif C – the gunman was born in Strasbourg and was already known to the security services as a possible terrorist threat.
He was the subject of a “fiche S”, a watchlist of people who represent a potential threat to national security.
He also had 27 convictions spanning across France, Germany and Switzerland, and has spent considerable time in prison as a result.
Police were seeking him on Tuesday morning in connection with another case, but did not find him at home.
However Mr Nuñez said his crimes had never been terrorism-related. But, he added, it was during one period in prison that he was indentified as having become radicalised.
“The fact he was a ‘fiche S’ did not pre-judge his level of dangerousness,” Mr Nuñez told France Inter.
A search of his home revealed a grenade, a rifle, four knives, two of which were hunting knives, and ammunition.
What about the victims?
Thai media have named Anupong Suebsamarn, 45, as one of the dead. He is believed to have been on holiday with his wife.
Not much else is known yet, apart from the fact no children were hurt and one soldier was slightly injured by a ricocheting bullet.
Why is Strasbourg a target?
Strasbourg has been the target of jihadist plots in the past.
Not only does it have one of France’s oldest Christmas markets, but it is the official seat of the European Parliament. That parliament was in session at the time of Tuesday evening’s attack.
In 2000, the Christmas market was at the centre of a failed al-Qaeda plot. Ten Islamist militants were jailed four years later for their part in the planned New Year’s Eve attack.
Security has been tight there ever since the 2015 Paris attacks.
However, MEPs were determined to carry on the morning after the attack, with German MEP Jo Leinen posting a picture of singing and Christmas lights in the European Parliament. BBC