A gunman who opened fire on a high-speed train travelling from Amsterdam to Paris was beaten unconscious by three Americans.
Two of them were soldiers, and one was taken to hospital with serious injuries, while another passenger on the train was wounded in the throat.
President Barack Obama said the heroic actions of the Americans may have prevented a far worse tragedy.
Anthony Sadler, a student at Sacramento State University in California told The Associated Press that his two travelling companions were in the military.
He said the injured American was Spencer Stone of Sacramento, and the other was Alek Skarlatos of Roseburg, Oregon.
"We heard a gunshot, and we heard glass breaking behind us, and saw a train employee sprint past us down the aisle," Mr Sadler said.
They saw a gunman entering the train car with an automatic rifle, he said.
"As he was cocking it to shoot it, Alek just yells, 'Spencer, go!' And Spencer runs down the aisle," Mr Sadler said.
"Spencer makes first contact, he tackles the guy, Alek wrestles gun away from him, and the gunman pulls out a box cutter and slices Spencer a few times. And the three of us beat him until he was unconscious."
He added: "The gunman never said a word."
Mr Stone helped another passenger who had been wounded in the throat and losing blood, Mr Sadler said.
The suspect is a 26-year-old Moroccan, according to Sliman Hamzi, an official with the police union Alliance, who spoke on French television station i-Tele.
Investigators from France's special anti-terror police are leading the investigation, a spokeswoman for the Paris prosecutor's office said.
In Washington, the Pentagon said it "can only confirm that one US military member was injured in the incident. The injury is not life-threatening."
The White House issued a statement saying that Mr Obama was briefed on the shooting, and said: "While the investigation into the attack is in its early stages, it is clear that their heroic actions may have prevented a far worse tragedy."
French interior minister Bernard Cazeneuve, speaking in Arras in northern France where the suspect was detained, said: "As always where an act that could be terrorist in nature is involved, the greatest care and the greatest precision will be used."
He said the Americans "were particularly courageous and showed great bravery in very difficult circumstances," and that "without their sangfroid we could have been confronted with a terrible drama".
Philippe Lorthiois, an official with the Alliance police unionLorthiois said contrary to earlier reports, the attacker did not fire his automatic weapon but wounded one man with a handgun and the other with a blade of some kind.
A third person, French actor Jean-Hugues Anglade, suffered a minor injury while activating the train's emergency alarm, he said.
The attack took place at while the Thalys train was passing through Belgium, according to a statement from the office of France president Francois Hollande.
He said he has spoken with Belgian prime minister Charles Michel, and the two leaders pledged to co-operate closely on the investigation.
Passenger Christina Coons of New York described the drama in carriage 12 of the train in an interview with Ouest France newspaper.
"I heard shots, most likely two, and a guy collapsed," she said.
Ms Coons, identified as a 28-year-old on holiday in Europe, said a window broke above one woman's head: "A guy fell to the floor and had blood everywhere."
She described lying on the floor herself and taking photos with her phone.
"I thought there would be a shoot-out in the train," she said.
Europe's major railway stations, such as Paris' Gare du Nord and Brussels' Gare du Midi, are patrolled by soldiers armed with rifles, but passengers can board most high-speed trains without passing through metal detectors or having their bags searched.
One exception is the Eurostar between Paris and London. Passengers on those trains must pass through a metal detector and have their bags scanned as well.
Thalys is owned by the French and Belgian railways and operates high-speed trains serving Paris, Brussels, Amsterdam and Cologne, Germany.
French authorities have been on heightened alert since Islamic extremist attacks in January left 20 people dead, including the three attackers.
Mr Stone is with the Air Force stationed in the Azores and Mr Skarlotos, a 22-year-old National Guardsman, had returned from a deployment in Afghanistan in July, according to his stepmother Karen Skarlotos.
She spoke to her stepson immediately after the incident: "He sounded fine, but he was intense - he sounded like he had just thwarted a terrorist attack.
"Alek and Spencer, they're big, brave, strong guys and they decided they were going to tackle him. And they did. Spencer tackled him, and Alek took the gun and clobbered him a good one," she told the AP from Oregon.
"Spencer got a couple good slices on him. But they were able to subdue him while the train was still moving."