A man killed two police officers and a bystander Tuesday in the Belgian city of Liege before he was fatally shot in what prosecutors are investigating as a terrorist attack, a prosecutor said.

The attacker, who was not immediately named by Belgian authorities, had been in prison since 2003 and was allowed out Monday on a two-day leave, Belgian Justice Minister Koen Geens said. The furlough put Belgian officials on the defensive about whether they should have been able to predict that the man was a security risk.

The incident unfolded at midmorning in the center of Liege, the third-largest city in Belgium, when the man came up behind two female police officers and attacked them with a knife, then grabbed one of their handguns and shot both dead, prosecutor Philippe Dulieu said.

Then the attacker shot a 22-year-old man who was sitting in the passenger seat of a nearby parked car. The assailant next walked into a school, where he took a woman hostage and forced a standoff with police during which students were evacuated. The man was subsequently killed in a gun battle with police officers who rushed to the scene, Dulieu said.

“An investigation into the incident was opened over a presumed terrorist offense,” Dulieu said.

Geens said that the prisoner had been allowed 13 previous two-day prison leaves as a way to prepare him for his eventual release in 2020 and that none had gone badly.

Forensic police officers work Tuesday at the scene of a shooting in Liege, Belgium. (Geert Vanden Wijngaert/AP)

He said authorities were trying to determine whether the man became radicalized while in prison. European counterterrorism officials have struggled with how to prevent the spread of terrorist ideology in prisons, where common criminals with no records of radicalism sometimes pick up extremist views.

Citing anonymous security officials, Belgian media reported that the attacker was a 36-year-old man with a history of small-time theft and drug violations.

The problem of radicalization has grown increasingly difficult in recent years as European citizens who fought for the Islamic State in Syria and Iraq return to Europe, often immediately facing stints in prison.

Geens said authorities were still trying to determine the motivation for the attack.

“It is not a clear-cut case. On the contrary,” Geens said. “It is certainly not someone who is obviously eligible to be qualified as radicalized.”

Still, Belgian prosecutors typically do not treat cases as terrorism investigations unless they have strong suspicions that they need to call in the additional resources, a law enforcement official with knowledge of the investigation said, speaking on the condition of anonymity because the official was not authorized to speak publicly.

“It was clear the objective of the killer was to attack the police,” the Liege police chief, Christian Beaupère, told reporters. He identified the police victims as Soraya Belkacemi, 53, and Lucile Garcia, 45. The third victim, Cyril Vangriecken, was about to start a career as a teacher, local media reported.

The attack unsettled Belgium, which is nervous about terrorism after a Brussels-based Islamic State ring was involved in attacks in Paris in November 2015 and Brussels in March 2016 that killed a total of 162 people. But the Belgian agency charged with setting the national alert level did not immediately raise its threat assessment, suggesting it did not believe there was a broader risk of attacks.

Belgian King Philippe and Prime Minister Charles Michel visited the scene hours after the attack. 

Michel said it was too early to determine the cause of the violence. On Twitter, the Belgian leader called the attack “cowardly and blind.”