A Moroccan man who launched a terrorist attack on train travelling between Amsterdam and Paris has been jailed for life in France.
Heroic passengers, including off-duty US soldiers, thwarted the attack by Ayoub El Khazzani on the high-speed Thalys train.
El Khazzani had been armed with an AK-47 automatic rifle and 300 rounds of ammunition.
The August 2015 attack was the inspiration for a 2018 film, The 15:17 to Paris, directed by Clint Eastwood.
As El Khazzani, 31, was jailed, three accomplices were sentenced to between seven and 27 years.
The court ruled he would have committed "an indiscriminate attack" that would have been "particularly deadly", had it not been for "a combination of particularly improbable circumstances" including faulty ammunition and "the exceptional courage of the passengers".
El Khazzani showed no emotion as the verdict was read out.
The ruling came a day after a Paris court convicted 13 accomplices of the extremists who carried out attacks at the Charlie Hebdo magazine and a Jewish supermarket in Paris in January 2015.
Unlike El Khazzani, who was immediately apprehended, all of the gunmen in the Charlie Hebdo assault were killed after the massacres, leaving only their accomplices to go on trial.
El Khazzani was tackled by passengers shortly after emerging bare-chested and heavily armed from a toilet on the train.
"I am sorry to the bottom of my heart," El Khazzani told the court. "What I did tears me apart, it freezes the blood."
He said that he had renounced the plot at the last minute because he could not kill people.
But the prosecution said it was only faulty munitions and the bravery of other passengers that stopped a massacre. There were about 150 travellers in the carriage.
The passengers who intervened included three Americans who were holidaying in Europe.
Two of them, Spencer Stone and Aleksander Skarlatos, were off-duty servicemen.
"I don't feel like a hero because we were just doing what we had to do to survive," Mr Skarlatos said after giving evidence during the trial.
El Khazzani had claimed he acted under the orders of Belgian Abdelhamid Abaaoud, believed to have been a mastermind behind the November 2015 attacks in Paris, to kill American soldiers on the train.
The court ruled that the Americans had no distinctive insignia and the size of his arsenal indicated he planned a wider massacre.
Abaaoud was killed by police in a Paris suburb five days after he shot indiscriminately at packed cafe terraces in Paris on the night of the November 13 attacks in the French capital.
The verdicts in the Charlie Hebdo and Thalys trials come as France is on its highest security alert, after three attacks in recent months blamed on radicals.
In October 16, a young Chechen refugee killed teacher Samuel Paty, who had shown caricatures of the Prophet Mohammed to his pupils.