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.
Interior Minister Jan Jambon said the gunman, Benjamin Herman, had murdered a former prisoner he met while in jail.
Reports say the victim was Michael Wilmet, 30, a convicted drug dealer who was hit repeatedly with a hammer.
The two policewomen killed the next day have been identified as Lucile Garcia, 53, and Soraya Belkacemi, 45.
The third victim, 22-year-old Cyril Vangriecken, was sitting in the passenger seat of a nearby parked car when he was shot.
Prosecutors say they are treating the attacks as "terrorist murder".
The Islamic State group (IS), which has claimed previous attacks in Belgium, said it was behind the shootings, but has not offered any evidence to support this.
The gunman also took a cleaner hostage at a school before being killed by police. She was released unharmed.
Named only as Darifa by Belgian media, the cleaner said Herman had burst in and asked her two questions: was she a Muslim, and was she observing Ramadan?
She answered yes to both, she said, and he replied that he would not harm her. She then attempted to persuade him he should not be in the school with children.
Officials said the 31-year-old man had shouted "Allahu Akbar" ("God is greatest" in Arabic) several times during the attack.
He had been freed from prison on temporary release on Monday after serving time for theft and drug offences. Local media report that he may 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 asked 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."
Why was he released?
The gunman had been in and out of prison since he was a teenager and had had a criminal record that included assault and drug offences, police said.
He was released at 07:30 local time on Monday and, under the terms of the temporary release, was expected to return to jail on Tuesday. It was during this period that he launched the attacks.
Justice Minister Koen Geens defended the decision to release him, saying it was intended to help him prepare for his full release scheduled for 2020. He added that the attacker had been granted temporary leave numerous times before without incident.
But he admitted that he had to "examine" his conscience following the attacks.
"The question of whether this man should have been given leave is striking because he killed three completely innocent people with a wish to kill himself," he told RTBF radio.
"I feel responsible because I have responsibility for prisons."
More on previous attacks in Belgium:
The shooting unfolded late on Tuesday morning near a cafe in the city centre.
Prosecutors said the man had followed and "savagely" attacked the two female police officers, stabbing them repeatedly from behind with a knife before taking a gun from them and opening fire.
He fatally shot dead Mr Vangriecken, who had almost finished studying to become a teacher, as he sat in the parked car, according to RTBF.
The attacker then walked to a nearby school, where he briefly took the cleaner hostage.
When armed police officers arrived at the scene, the attacker fired at them in an attempt to escape. Two officers were shot in the leg, leaving one 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.
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. As with Tuesday's attacks, both the Paris and Brussels attacks were claimed by IS.