PARIS - He watches one last YouTube video of an Islamist preacher, then alone in the bathroom of a high-speed train he removes his shirt and grabs his assault rifle.
Ayoub El Khazzani is ready to commit a massacre, according to an account of the 40 terrifying minutes on a high-speed train from Amsterdam to Paris last week pieced together by French prosecutors and witness statements.
The 25-year-old Moroccan bought his first class ticket on the day of the attack - Friday, August 21 - at the Midi train station in Brussels, paying 149 euros ($170) in cash.
The ticket seller asks if he wants to travel earlier, on a less crowded train, but he refuses: it is the packed 15:17 Thalys train linking Amsterdam to Paris that he wants.
At 17:35, authorities say, he opens the bathroom door. He leaves behind some of his luggage - a roller suitcase and a small cannister of petrol - but strapped to his chest is a bag full of 270 rounds of ammunition and a second gun, a Luger M80 pistol.
In the hallway, a young French banker is waiting his turn for the washroom. When he sees the weapon, the young man grabs Khazzani with both hands, pushing him against a luggage rack.
For some 15 seconds they are locked together, Khazzani pinned by the weight of the banker's chest, according to Paris prosecutor Francois Molins - then, in the next car, controller Michel Bruet hears the struggle.
At first, he assumes it is nothing more than a brawl, before the 54-year-old realises Khazzani is armed. He rushes to help: "I was thrown against a door... he knocked me to the ground and pointed the handgun at me, then left the car." Khazzani takes aim at the young Frenchman, who wants to remain anonymous, and shoots. Glass breaks. In cars 11 and 12, there is panic. "We heard passengers screaming in English, 'He's shooting! He's got a Kalashnikov!'", said French actor Jean-Hugues Anglade, who was in car 11.
Suddenly, Anglade says, train crew members run into the corridor, hunched over, heading for the locomotive and lock themselves in.
Passengers pound on the door, shouting for the staff to let them in.
French rail authorities say the crew behind the locked door are catering staff hired by a sub-contractor.
Passengers leap from windows
In car 12, two Americans - 23-year-old US Air Force Airman Spencer Stone and 22-year-old National Guardsman Alek Skarlatos - are on their first holiday to Europe when they see a man enter the carriage with an assault rifle and a handgun.
"I turned to Spencer and I said, 'Let's go, let's go'," said Skarlatos, who had just returned from a nine-month tour of Afghanistan.
Khazzani makes an upward movement with his weapon - an AKM, an assault rifle similar to a Kalashnikov - and Stone sees his chance, tackling him to the ground.
Skarlatos grabs the gun but Khazzani pulls out his pistol and points it at Skarlatos and pulls the trigger - but no bullet comes out.
Stone wraps his hands around Khazzani's neck as the attacker fights back with a box cutter, slicing the American in his neck and thumb.
Skarlatos is still trying to disarm him and other passengers have rushed to help: their friend, student Anthony Sadler, lays into him; Briton Christopher Norman has grabbed Khazzani's right arm; and Eric Tanty, an off-duty Thalys driver, holds down his left.
At least one more shot is fired during the struggle, the bullet hitting Mark Moogalian, a 51-year-old French-American, in the neck.
Then Khazzani loses consciousness. Quickly, he is tied up. By now the alarm has been given and the train has slowed down, but several panicked passengers break windows and jump out.
When the train arrives in Arras, Khazzani is arrested. Most of the 554 passengers on board do not even realise what has happened.