US servicemen have overpowered a gunman armed with a Kalashnikov who opened fire on a high-speed train travelling from Amsterdam to Paris.
According to initial information from investigators, two of the men who tackled the gunman were US troops who had apparently heard him loading his weapons in a toilet cubicle and confronted him after he came out.
Two people were wounded in the incident, with the Pentagon confirming that one was a member of the US military.
The gunman had a Kalashnikov, an automatic pistol and a box cutter, one police source said.
The suspect, who was arrested when the train stopped at the northern French town of Arras, was a 26-year-old from Morocco or of Moroccan origin who was known to the intelligence services, French investigators said.
US President Barack Obama praised the passengers for their actions.
"The president expressed his profound gratitude for the courage and quick thinking of several passengers, including US service members, who selflessly subdued the attacker," a White House official said.
"Their heroic actions may have prevented a far worse tragedy."
The motives for the shooting were not immediately known, although French prosecutors said counter-terrorism investigators had taken over the probe.
"I condemn the terrorist attack on the Thalys (train) and express my sympathy to the victims," Belgian Prime Minister Charles Michel said on Twitter of the incident, which occurred while the train was in Belgium.
The man opened fire at 5.50pm, train operator Thalys said.
The gunman was arrested 10 minutes later when the train, with 554 passengers on board, stopped at Arras station where armed police were waiting, a spokesman for the French state rail company SNCF said.
One of the passengers on the train, who asked to be identified only as Damien, 35, said he had heard the gunman shooting but initially thought the sound came from a toy.
"The man stopped between two carriages, fired and it made a click-click-click sound, not at all like in the films," he said.
"Then the man, who was bare-chested, returned to carriage 12 and someone in a green T-shirt, with a shaved head, saw him and jumped on him and pinned him to the ground."
French actor Jean-Hugues Anglade, who appeared in the 1986 cult film Betty Blue, suffered minor injuries as he tried to activate the train's alarm, a SNCF spokesman said.
The gunman had probably boarded the train in Brussels, a police source said.
Media reports said a Briton was also injured, but the Foreign Office in London said it had no reports of any British casualties.
The Department of Foreign Affairs and Trade has confirmed no Australians were injured in the incident.
French President Francois Hollande said "everything is being done to shed light" on the shooting.
US soldier injured in France train attack
One of the people injured in an attack on a French train was a US military member, the Pentagon says, amid media reports that two US marines overpowered the gunman and stopped a massacre.
"We are aware of the reports and can only confirm that one military member was injured in the incident," Pentagon spokesman Commander William Urban said.
Urban said the servicemember's injuries were not life-threatening.
No more information was immediately available.
The gunman opened fire on a high-speed train travelling from Amsterdam to Paris on Friday, injuring at least two people before he was overpowered by two US passengers, French investigators said.
CNN reported that the marines, in civilian clothing, had overpowered a man who was loading his Kalashnikov assault rifle, and that the gunman had fired on the marines with a handgun.