The 15-year-old, who was arrested after the attack, had intended to kill his physics teacher, a local prosecutor said.
“He told investigators that he had been plotting for a week,” Christian de Rocquigny told the AFP news agency, adding that the teen planned to stab the teacher over a previous dispute before dying as a martyr.
The boy yelled “Allahu Akbar” (“God is greatest”) and “I will avenge the Prophet”, reported France TV, while armed with an airgun, a very low power “airsoft” grenade, and a knife.
The teacher escaped with minor injuries from the attack, which occurred on Monday morning at a high school in Châlons-en-Champagne, northern France.
Students were sent home while police arrested the teenager, who was then sent for psychiatric evaluation.
Education Minister Najat Vallaud-Belkacem expressed support for the teacher, and said in a statement that the ministry “reaffirms its commitment to preventing and fighting against all forms of violence in schools”.