The French anti-terrorism prosecutor opened an investigation concerning murder with a suspected terrorist motive, the prosecutor's office said.
The gruesome killing of the teacher occurred in the town of Conflans-Sainte-Honorine while the suspect was killed by police in adjoining Eragny. The towns are located in the Val d'Oise region northwest of Paris.
President Emmanuel Macron was travelling to the area.
A police official said the suspect, armed with a knife and an airsoft gun - which fires plastic pellets - was shot dead about 600 meters (yards) from where the male teacher was killed after he failed to respond to orders to put down his arms, and acted in a threatening manner.
The teacher had received threats after opening a discussion "for a debate" about the caricatures about 10 days ago, the police official told
The Associated Press. The parent of a student had filed a complaint against the teacher, another police official said, adding that the suspected killer did not have a child at the school. The suspect's identity was not made public.
The two officials could not be named because they were not authorized to discuss ongoing investigations.
"We didn't see this coming," Conflans resident Remi Tell said on CNews TV station.
He described the town as peaceful.
It was the second terrorism-related incident since the opening of an ongoing trial on the newsroom massacre in Jan. 2015 at the satirical newspaper Charlie Hebdo after the publication of caricatures of the prophet of Islam.
As the trial opened, the paper republished caricatures of the prophet to underscore the right of freedom of expression. Exactly three weeks ago, a young man from Pakistan was arrested after stabbing, outside the newspaper's former offices, two people who suffered non life-threatening injuries.
The 18-year-old told police he was upset about the publication of the caricatures.
The incident came as Macron's government is working on a bill to address Islamist radicals who authorities claim are creating a parallel society outside the values of the French Republic.