The gunman who killed a French cop on the Champs-Elysees in Paris had served time for armed assaults on law enforcement authorities — and was detained this year for threatening police, then freed, police sources said Friday.

The attacker — identified as Karim Cheurfi — opened fire on a police van parked on the famed boulevard late Thursday, killing one cop and seriously injuring two others before being shot dead.

The French national, who lived in the eastern Paris suburb of Chelles, had been convicted for armed assaults on law enforcement officers going back 16 years, sources told Reuters.

He had served nearly 15 years after being convicted of three attempted murders — two against police officers — in 2001, The Guardian of the UK reported.

While in the slammer, Cheurfi, 39, had also shot and wounded a prison guard after seizing his gun.

Eventually released after serving most of his sentence, he was arrested again in February on suspicion of preparing to attack police — but released for lack of evidence.

But he reportedly was not on France’s “Fiche-S,” the list of those suspected of being threats to national security, The Guardian reported.

Three of his family members have been detained, the French Interior Ministry announced Friday.

In addition to the assault rifle used in the attack, he had a pump-action shotgun and knives in his vehicle, the sources said.

The ISIS terror group claimed responsibility for the Champs-Elysees shooting, identifying the attacker in a statement by the group’s propaganda agency, Amaq, as “Abu Yousif the Belgian.”

It was unclear if the statement referred to Cheurfi.

A Belgian national sought earlier by Belgian authorities and thought to have traveled to France on Thursday turned himself in to police in Antwerp, French Interior Ministry spokesman Henri Brandet said Friday, according to The Guardian.

A French source said the 35-year-old Belgian had been sought by his country’s police as part of a separate probe.

Hours before the Paris attack, Belgian police reportedly found weapons and a ticket for a train trip to France departing Thursday morning, the paper reported.

Belgian prosecutors said the man turned himself in “after he saw himself appear on social media as terror suspect No. 1,” but that he had nothing to do with the deadly attack.

The man was identified as Youssouf El Osri in a document seen by Reuters.

Belgian officials had warned French authorities before the attack that El Osri was a “very dangerous individual en route to France” aboard a high-speed train.

El Osri’s connection with either Cheurfi or the man named in the jihadi group’s statement remained unclear Friday.

Meanwhile, authorities searched a house in Chelles that was believed to be Cheurfi’s family home. The Le Parisien newspaper said the address matched that of the owner of the car used in the attack.

French President François Hollande said authorities were convinced the Champs-Elysees shooting was a terror attack and expressed “great sadness” over the police officer’s death.

Coming just days after police said they had thwarted another planned Islamist attack, arresting two men in the southern city of Marseille, Thursday’s shooting dominated the final day of election campaigning.

Conservative candidate Francois Fillon and Marine Le Pen, leader of the far-right National Front, stressed their tough law-and-order stances — while centrist front-runner Emmanuel Macron stressed he also was up to the challenge.

France has been on its highest level of terror alert since the 2015 Charlie Hebdo and Paris attacks, and the Nice truck attack of 2016.

Meanwhile, tourists were back on the Champs-Elysees early Friday with a mixture of shock and defiance.

“I needed to get out, to come back here and see the sunshine and that everything was OK,” Lebanese tourist Zeina Bitar, 45, who was shopping on the boulevard with her children when the gunman struck, told Agence France-Presse.

Eric Winkler, 51, a tourist from Boston, told AFP: “It was scary. We heard the shots so we ran to our hotel … and found out it was terrorism by watching the news.”

But he and his 16-year-old daughter, Hailey, took it in stride.

“It’s happening all over the world, also in America,” Winkler said. “We have to deal with it, they’re not going to stop us from living and doing what we want to do.”

With Post wires