The man who shot dead two police officers and a civilian in the Belgian city of Liège had killed someone the night before the attacks, the country’s interior minister says.
Jan Jambon said the gunman, named as Benjamin Herman, had murdered a man – a former prisoner – he met while in jail.
He added that the authorities were working to establish a motive.
The gunman also took a female cleaner hostage at a school before being killed by police.
Police sources quoted in local media said the man was heard shouting “Allahu Akbar” (“God is greatest” in Arabic).
Belgian broadcaster RTBF said the gunman was let out from prison on temporary release on Monday where he had been serving time on drug offences. It said he might have been radicalised while in jail.
“There are signs he was radicalised in prison, but is it that radicalisation which drove him to commit these acts?” Mr Jambon said on RTL radio.
“It could have been because he had nothing to look forward to, because he also killed someone the night before, the guy’s psychology and the fact… he may have been on drugs.”
The shooting unfolded late on Tuesday morning near a cafe in the city centre.
Prosecutors said the man followed and “savagely” attacked the two women officers from behind with a knife before taking a gun from them and opening fire.
He also shot dead a 22-year-old man who was sitting in the passenger seat of a parked car. He then walked to a nearby school, where he briefly took a member of staff hostage.
Armed police officers with shields, helmets and bulletproof vests then arrived at the scene and “intervened”.
The attacker began firing at the officers in an attempt to escape. Two officers were shot in the leg, leaving one officer in a serious condition.
Two other officers received injuries to their arms before the attacker was shot dead, prosecutors said.
Footage on social media showed people running to safety as several gunshots rang out. Children at the school were moved to safety.
What’s the wider situation?
Belgium remains on alert after a series of jihadist attacks in the country and in neighbouring France.
A Brussels-based cell was involved in the 2015 Paris attacks which left 130 people dead in several locations.
Brussels itself saw three suicide bombings in March 2016, with 32 people killed. Both the Paris and Brussels attacks were claimed by the Islamic State-group.
Later in 2016 a man attacked two police officers with machetes while shouting “Allahu Akbar” before being shot dead.