A prison inmate on an extremist watchlist was given a two-day furlough in Belgium — and promptly killed two female cops and a civilian while shouting “Allahu Akbar!’’ during the terror attack, police said Tuesday.

Drug con-turned-extremist Benjamin Herman, 36, walked out of prison near the eastern city of Liège on Monday night as part of the country’s rehabilitation program to help inmates assimilate back into society once they are released, authorities said.

By 10:30 a.m. Tuesday, the Belgian-born man — who was on a police watchlist because of his contacts with Islamic extremists, according to Agence France- Presse — was hunting cops with a knife.

“The goal of the attacker was to target the police,” said Liège Police Chief Christian Beaupere.

Herman followed two policewomen into Café des Augustins near the city center, stabbing them multiple times in the back.

He then grabbed one of the cop’s handguns and shot them both dead.

The officers were identified as Soraya Belkacemi, 53, and Lucile Garcia, 45 — both the wives of fellow law-enforcement officers.

Belkacemi was the mother of twin 13-year-old girls, while Garcia wed her boyfriend of 14 years only last month and recently became a grandmother.

After killing the cops, Herman then walked down the street and fatally fired at Cyril Vangriecken, 22, as he sat in a parked car next to his mother, according to the Dutch language newspaper Laaste Nieuws.

The attacker then ran into a local high school, where he took a female janitor hostage.

During a standoff with cops, Herman ran out into the street with his gun blazing, injuring four officers, including one who suffered a severed femoral artery in a leg.

Police sources told local media that the gunman was heard shouting, “Allahu Akbar!” — or “God is great” in Arabic — before opening fire.

Herman was shot dead.

“The event is classed as a terrorist incident,” said prosecutor Philippe Dulieu.

As questions mounted about whether Herman should have been allowed furlough, Belgian Prime Minister Charles Michel insisted that the gunman was indirectly mentioned in security reports on radicalization but not on any official list kept by anti-terror authorities.

Herman had been serving a sentence since 2003 for petty offenses and drug-dealing and was set to be released in two years, Justice Minister Koen Geens said.

Geens said that Monday was the 14th time that Herman had been briefly allowed out.

“When something goes right 13 times, then it normally doesn’t go wrong the 14th time,” Geens said. “But these leaves are always risky in the prison world. That’s unavoidable.”

Investigators are looking into whether Herman was radicalized in prison, authorities said.

A Koran and prayer rug were found in his cell, according to Paris-Match magazine.

Michel and Belgian King Phillippe visited Liège to pay their respects to the victims.

In 2016, a Brussels-based ISIS cell perpetrated coordinated attacks at the capital city’s airport and a metro station that killed 32. The same cell helped carry out attacks on Paris in 2015 that left 130 dead.

With Post wires