The man who beheaded a teacher in a street in France waited outside a school and asked pupils to identify his target, anti-terrorism officials say.
The man then posted images on social media of dead victim Samuel Paty, 47, who had shown controversial cartoons of the Prophet Muhammad to his students.
The attacker later fired at police with an airgun before being shot dead.
Nine people have been arrested and are being investigated for possible links to Islamic extremism.
The attack took place at about 17:00 (15:00 GMT) on Friday near the College du Bois d’Aulne, where Mr Paty taught, in the town of Conflans-Sainte-Honorine, some 30km (20 miles) north-west of central Paris.
President Emmanuel Macron said the attack bore all the hallmarks of an “Islamist terrorist attack” and that the teacher had been murdered because he “taught freedom of expression.”
A national tribute will be paid to Mr Paty.
What is the latest on the attack?
Details of the attack and the investigation were given by the anti-terrorism state prosecutor, Jean-François Ricard.
He named the suspect as Abdoulakh A. – an 18-year-old man, born in Moscow of Chechen origin. He came to France with refugee status as a boy and was unknown to anti-terrorism police.
He lived in the Normandy town of Évreux, about 100km (62 miles) from the murder scene, and had no apparent connection with the teacher or the school.
The man had been before the courts but only on minor misdemeanour charges.
He went to the college on Friday afternoon and asked students to point out the teacher, Mr Ricard said.
The attacker followed Mr Paty, who was heading home on foot after school, inflicted multiple wounds to the head with a knife and then beheaded the victim.
Witnesses are said to have heard the attacker shout “Allahu Akbar” or “God is Greatest.”
The man then posted photos of the victim to a Twitter account, along with insults to Mr Macron and French “infidels” and “dogs.”
As police approached him, he fired rounds from an airgun at police, Mr Ricard said.
They returned fire. The suspect tried to get up and was shot again, being hit nine times in all.
A 30cm-long (12in) blade was found close by.
What about the investigation?
Mr Ricard said Mr Paty had been the target of threats after he showed cartoons of the Prophet Muhammad during a class about freedom of speech in relation to the Charlie Hebdo case.
The French satirical magazine was the subject of a deadly attack in 2015 after publishing cartoons. A trial over that attack is currently under way.
Mr Paty, a history and geography teacher, advised Muslim students to look away if they thought they might be offended.
A parent of one of the pupils reacted angrily to the incident, accusing Mr Paty of showing naked pictures of the Prophet Muhammad. The father lodged a formal complaint and produced videos demonstrating his anger at Mr Paty’s actions, and calling on people to go to the school to protest.
The father was one of the people in custody, Mr Ricard said, adding that the man’s half-sister had joined the Islamic State organisation in Syria in 2014.
At least one of the other people arrested was known to anti-terrorism police, he said, with other links being investigated.
At least four of those arrested are relatives of the attacker.
Mr Ricard said this was the second attack since the Charlie Hebdo trial got under way. A man attacked and wounded two people outside the magazine’s former offices.
Mr Ricard said there was an “ongoing extremely high level of terrorism threat on French soil.”
Teachers across France told journalists of their fears, stunned by the targeting of a colleague murdered in broad daylight in a quiet suburban street.
Aside from the horror of this killing, there’s powerful symbolism too. The education minister said the root of what happened was “hatred of the Republic.”
The passing on of French national values – liberty, equality, fraternity – is seen as a core task of the education system here.
Three weeks after an attack on the former offices of Charlie Hebdo, this latest killing is yet more proof of the fault-lines over secularism and tolerance, which have left blood on the country’s streets.
How is France reacting?
Students were said to be distraught at the brutal killing of a well-liked teacher. One father wrote on Twitter that his daughter “is in pieces, terrorised by the violence of such an act. How will I explain to her the unthinkable?”
One of Mr Paty’s former students, Martial, 16, said he loved his job: “He really wanted to teach us things – sometimes we had debates.”
The French presidency said a national tribute would be held for Mr Paty, and the hashtag #JeSuisSamuel (I am Samuel) began trending on social media, echoing the #JeSuisCharlie call for solidarity after the attack on Charlie Hebdo.
Speaking at the scene hours after the incident, President Macron stressed national unity. “They will not prevail, they will not divide us,” he said.
Charlie Hebdo on Friday tweeted: “Intolerance has just reached a new threshold and seems to stop at nothing to impose terror on our country.”
Education Minister Jean-Michel Blanquer, who met leaders from teaching unions on Saturday, said in a recorded statement that Mr Paty had been killed by the “enemies of freedom” and that France would “never back down when confronted by terror, intimidation”.
Muslim leaders in France also condemned the attack. “Civilisation does not kill an innocent person, barbarism does,” Tareq Oubrou, imam of a mosque in Bordeaux, told France Inter.
The Strasbourg-based Assembly of Chechens in Europe said in a statement: “Like all French people, our community is horrified by this incident.” BBC News