PARIS — A knife-wielding man decapitated a teacher near a school in a suburb north of Paris on Friday afternoon and was later shot dead by the police, officials said, abruptly hitting France with a national trauma that revived memories of recent terrorist attacks.
A police officer and parents with knowledge of the attack confirmed French media reports that the victim was a history teacher at the school who had shown caricatures of the Prophet Muhammad in a class on freedom of expression, which had incited anger among some Muslim families.
The teacher, still unidentified by Friday evening, was immediately depicted as a martyr to freedom of expression across the political spectrum. Representatives in France’s Parliament rose to their feet to “honor the victim’s memory,” as the president of the session, parliamentary deputy Hugues Renson, declared. And President Emmanuel Macron hurried to the scene of the attack Friday night.
“This was an attempt to strike down the republic,” Mr. Macron said.
Seizing on the symbolic nature of an attack against a high school teacher, and reprising anti-Islamist themes he has lately emphasized, Mr. Macron said the teacher had been “the victim of a terrorist, Islamist attack.”
The teacher was struck down “because he taught, because he taught the liberty of expression, the liberty to believe and not believe,” the French president said in a brief televised address.
France’s antiterrorism prosecutors immediately took over the investigation of the attack, which happened at the junction of two adjoining Paris suburbs, Eragny and Conflans-Sainte-Honorine.
Much remained obscure Friday night in the absence of an official police narrative. But the underlying themes of what was known conjured up France’s recent history of terrorist attacks: an assailant carefully choosing a victim thought to symbolize an offense against Islam.
Turmoil at the school over the teacher’s method of instruction — Mr. Macron alluded to this in his remarks — had evidently preceded the killing. “We have seen the principal, who in these last weeks has withstood with remarkable courage a great deal of pressure,” Mr. Macron said.
In a video that widely circulated on YouTube before the attack, a Muslim parent at the teacher’s school, College du Bois-d’Aulne, expresses anger that an unidentified teacher had asked Muslims in the class of 13-year-olds to leave because “he was going to show a photo that would shock them.”
The parent asks on the video: “Why this hatred? Why does a history teacher act like this in front of 13-year-olds?”
The assailant is not known to have a connection to the school. French media reported that he was 18 and of Russian origin.
A police union official told the French television station BFM that witnesses had seen the assailant cutting the victim’s throat. The national police were called, officials said, and after having discovered the decapitated victim, confronted the assailant nearby, close to the school. Brandishing a large knife, he threatened the officers, and after refusing to surrender, was shot 10 times, they said.
French media, quoting witnesses, said the assailant was heard to yell “Allahu akbar” at the moment of the knife attack. A photograph of a corpse lying in the middle of a leafy suburban street appeared on French television not long afterward.
The attack came three weeks after a knife-wielding assailant wounded two people in Paris near the site of the former Charlie Hebdo office — the scene of a 2015 terrorist attack targeting the satirical newspaper for its caricatures of the Prophet Muhammad.
French officials of all political stripes rushed to denounce the teacher’s killing. The interior minister, in charge of the police, cut short an official trip to Morocco and flew home to Paris.
“The assassination of a history teacher is an attack on freedom of expression and the values of the republic,” the president of the National Assembly, Richard Ferrand, said on Twitter. “To attack a teacher is to attack all French citizens and freedom.”
“Frightful. Huge emotion and anger in the face of this terrorist barbarism,” a leading Socialist parliamentarian, Boris Vallaud, wrote on Twitter.
In the video, the parent details what his daughter told him had transpired in the class.
“So this week, he allowed himself to tell them, the Muslims, Muslim students raise your hands,” the parents says. “So they raised their hands, and he said, ‘right, leave the class.’ So my daughter refused to leave and asked him, ‘why?’ And he said he was going to show a photo that would shock them. And then he showed them a naked man, telling them it was the prophet.”
Another parent, Carine Mendes, 41, whose child had attended the class, offered a more nuanced view of what happened. She called the teacher “a very sweet person, in his words, in his expressions.”
Ms. Mendes said the teacher had suggested to Muslim students who did not want to see the cartoon that they leave the classroom temporarily, and had asked those who remained not to tell their Muslim classmates about the cartoon in order not to offend their faith.
“He really tried to do things with respect, he didn’t want to hurt anyone,” she said.
But in a second class where the teacher gave the course, a shocked student refused to leave the room and told her father about what happened. He was the father who later complained in the video posted online.
The next day, the teacher apologized to his students and the principal sent an email message to parents to try to clear up the situation. The teacher’s suggestion to leave the classroom, the principal said, had been insensitive.
“Without wanting to offend anyone, it turned out that by offering this possibility to the students, he still offended the student,” the principal’s email read.
Ms. Mendes said that what happened “was awful.”
“He was just giving a course on freedom of expression,” she said.
“A teacher was killed just for doing his job,” Sophie Venetitay, a teachers’ union official, told BFM.
Constant Méheut and Antonella Francini contributed reporting.