The man who beheaded a teacher in a street in France waited outside the 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 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 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 Evreux, about 100km (62 miles) from the murder scene and had no apparent connection with the teacher or the school.
The man had been before 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 since he showed the 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 the 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 the anger at Mr Paty’s actions, and calling on people to go to the school to protest.
The father is one of the people in custody, Mr Ricard said, adding that this 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.
And 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 fear, 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 before in 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 unthink