PARIS — A high school teacher in a Paris suburb was decapitated Friday afternoon, French authorities said, in an attack that occurred after the teacher had allegedly shown caricatures of the prophet Muhammad to his students.

The attack occurred after 5 p.m. near a school in the Paris suburb of Conflans-Saint-Honorine to the northwest of Paris, according to French news reports. French police shot the suspect in a nearby town, killing him, said French police sources cited in news reports.

France’s national anti-terror prosecutor immediately opened an investigation for “murder in connection with a terrorist enterprise” and “criminal terrorist association.” French President Emmanuel Macron planned to go to the crime scene, and Interior Minister Gerard Darmanin returned to Paris from an official visit to Morocco.

French media identified the victim as a high school history and geography teacher. Parents in the area had recently complained that a local teacher had shown students caricatures of the prophet Muhammad as part of a lesson on freedom of expression, France’s BFM television reported.

As authorities worked to establish a more complete picture, the potential motive of seeking revenge for the Muhammad cartoons led investigators to quickly consider the case a terrorist attack, Le Monde reported.

“Tonight, it was the Republic that was attacked with the despicable assassination of one of its servants, a professor,” said Education Minister Jean-Michel Blanquer. “I think tonight of him, of his family. Our unity and steadfastness are the only answers to the monstrosity of Islamist terrorism.”

Friday’s attack comes amid the historic trial of 14 alleged accomplices in the January 2015 attack on Charlie Hebdo, a satirical newspaper that had previously published cartoons that depicted the likeness of Muhammad, which is strictly prohibited by the Muslim faith. The two attackers in the 2015 shooting were recorded saying that they had avenged the prophet as they fled the scene.

Last month, Charlie Hebdo’s editors commemorated the beginning of the trial by publishing new cartoons of Muhammad.

Weeks later, two people were stabbed outside the former Paris offices of Charlie Hebdo in an assault that authorities later said had been designed to attack the newspaper’s journalists a second time.

Against the backdrop of these attacks, Macron unveiled plans for combating what he called “Islamist separatism” this month. In a long-awaited speech, Macron called Islam “a religion that is in crisis all over the world,” with problems that stem from a “very strong hardening” of positions among Muslims.