A man has shot dead two police officers and a civilian in the eastern Belgian city of Liège.
The gunman also took a cleaner hostage at a school before being killed by police. Four other police officers were also injured.
The man's motive is not yet clear but the incident is being treated as terrorism.
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 that he may have been radicalised while in jail.
Liège mayor Willy Demeyer confirmed the deaths of the two female officers during a press conference and said that "physical and psychological support" would be provided to the families of the victims.
The shooting unfolded late morning on Tuesday near a cafe in the city centre.
Prosecutors said the man followed and "savagely" attacked the 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 as he walked in the direction of a nearby school, where he briefly took a member of staff hostage.
"The young man who was killed in the vehicle was a pupil of the high school in Liège, he was going to qualify as a primary school teacher in the next few weeks," Mr Demeyer said.
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.
Liège city authorities later tweeted: "The children in the local schools are safe."
Belgium's Prime Minister Charles Michel said he was following the situation closely and expressed his support for those caught up in the shooting.
Belgium's Interior Minister Jan Jambon said that investigators were trying to establish "exactly what happened" and that "our thoughts are with the victims of this horrible act."
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 had 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.