France’s anti-terror prosecutor has said that a suspected Islamic extremist declared allegiance to the so-called Islamic State group before fatally stabbing a teacher in a school attack last week.

Jean-Francois Ricard said the alleged attacker, in an audio recording in on his phone, declared allegiance to IS and expressed “his hatred for France, for the French, for democracy and the education he benefited from in our country”.

The alleged attacker was a former pupil of the school in the northern town of Arras.

A teacher was fatally stabbed in the neck and three other people injured in the assault that prompted France to raise its terror alert level and deploy extra security.

The prosecutor spoke at a press conference and took no questions.

France Attacker Islamic State
French national counter-terrorism prosecutor Jean-Francois Ricard spoke to the media (Michel Euler/AP)

Mr Ricard said that shortly before the stabbing, the alleged attacker also recorded a 30-second video of himself in front of a war memorial.

The prosecutor identified the suspect only as Mohamed M, without his last name — a common practice in French judicial investigations.

Court documents reviewed by the Associated Press show the suspect, born in 2003, is from the Ingushetia region in Russia’s Caucasus Mountains, which neighbours Chechnya.

In his video, the suspect “repeatedly attacked, in his own words, the values of the French. He expressed some particularly threatening views”, the prosecutor said.

In the audio message, recorded in Arabic, the suspect also expressed support for Muslims in Iraq, Asia and the Palestinian territories but did not directly link the school attack to the outbreak of war between the Hamas militant group and Israel, the prosecutor said.

Two of the alleged attacker’s family members, as well the suspect himself, now face formal terrorism-related charges, Mr Ricard said.

They include the alleged attacker’s 16-year-old younger brother who is suspected of having provided “a certain amount of support” for the assault, of being aware of his older brother’s radicalisation and of advising him how to handle knives.

The other is a cousin who was allegedly aware that a crime was possibly being planned but did nothing to stop it, Mr Ricard said.

Police have detained a total of 13 people for questioning since last Friday but 10 of those have been cleared of any wrongdoing for now, the prosecutor said.