A machine gun-toting attacker wounded three people on a high-speed train in France on Friday before being overpowered by passengers who included an American soldier.
Officials said the attacker was arrested after the shooting when the Amsterdam-to-Paris train stopped at Arras station in northern France.
French Interior Minister Bernard Cazeneuve said the French anti-terrorism prosecutor was investigating the incident and that the gunman's motives were not known.
The wounded included the U.S. citizen and French actor Jean-Hugues Anglade, Cazeneuve said.
Chris Norman, a 62-year-old British consultant, told reporters he had been sitting in the same carriage as the Americans when they heard a shot.
"I looked up and saw a guy carrying an AK-47 or at least I assume it was some kind of machine-gun," he said. "It could have been a real carnage, there's no question about that."
Alek Skarlatos, a 22-year-old member of the U.S. National Guard from Oregon, said his friend, who is also in the military, had been injured while he grappled with the gunman. They eventually got the attacker under control, Norman said.
"I just got back from Afghanistan last month, and this was my vacation from Afghanistan," Skarlatos said.
British media cited a Foreign Office official saying no British national had been injured, as had been previously reported by the French interior ministry.
France has been on high security alert since Islamist militants killed 17 people in and around Paris in January, among them staff of satirical weekly Charlie Hebdo and hostages held in a Jewish shop.
Commending the involvement of what he said were two U.S. citizens, Cazeneuve said: "Without their courage, we would have surely faced a terrible tragedy."
A spokesman for the United States European Command confirmed that one of the passengers who had been injured was a U.S. soldier, and said his life was not in danger.
Cazeneuve urged caution over the nature of the attack, which he said was a matter for the prosecutor to investigate.
"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.
A spokesman for French railway SNCF said on iTele television: "The man was armed with automatic weapons and blades. He was stopped by passengers." A statement from SNCF's European affiliate Thalys said the attacker got on its train in Brussels.
Police union official Slimane Hamzi said the 26-year-old man was armed with a kalashnikov and had said he was of Moroccan origin.
Since the January attacks in Paris there have been other incidents. In June, a suspected Islamist beheaded his boss and tried to blow up a U.S-owned industrial gas plant in the suburbs of Lyon.
And in July, French officials said they had prevented an attack on a senior French military official by arresting four people whose leader had links to jailed jihadists.
Thalys is partly owned by SNCF and Belgian railways and runs international trains joining France, Belgium, the Netherlands and Germany. All four countries are part of the Schengen area through which people travel without the need for passports and security check-ins.
French President Francois Hollande said he had talked to Belgian Prime Minister Charles Michel and that the two governments were cooperating in the investigation.
Michel said in a tweet, "I condemn the terrorist attack ... and express my sympathy for the victims."
The Belgian government is considering taking extra security measures, a spokesman said.