A heavily armed man who was overpowered on a train in France is thought to be known to the intelligence services, officials say.
French Interior Minister Bernard Cazeneuve said the gunman is believed to be a 26-year-old Moroccan with links to the “radical Islamist movement”.
He was restrained by passengers, including three Americans, two of whom are members of the armed forces.
They have been praised by the French and American presidents.
Mr Cazeneuve stressed that the identity of the suspect had not been “established with certainty”.
But he said that the man, who is being questioned near Paris, had identified himself as someone who was flagged up to French authorities by their Spanish counterparts in February 2014.
French and Spanish media identified him as Ayoub El-Kahzzani. He is reported to have lived in France, Spain, and Belgium and to have travelled to Syria.
The incident happened on a high-speed Thalys service near the northern city of Arras on Friday.
When a French passenger tried to enter a toilet, he encountered the gunman and tried to overpower him.
A gun was fired and a French-American passenger was injured by the bullet.
The gunman was carrying a Kalashnikov rifle, an automatic pistol with ammunition clips, and a box cutter knife, Mr Cazeneuve said.
One of the Americans, Spencer Stone, seized the gunman, while a second, Alek Skarlatos, grabbed his guns, according to accounts from the passengers.
A friend of theirs, Anthony Sadler, and Chris Norman, a British man who lives in France, also helped restrain the attacker.
Mr Norman told reporters on Saturday that he initially hid when he saw the gunman running down the aisle, before deciding that “perhaps the only chance was to act as a team”.
“He had a Kalashnikov – I don’t know how many magazines he had. My thought was, ‘I’m probably going to die anyway so, let’s go’,” he said.
“I jumped up and I was actually the fourth person to begin working on the terrorist.”
With Mr Stone holding the gunman in a headlock, the passengers hit him until he fell unconscious.
The gunman injured Mr Stone with a knife. Mr Stone and another man, who received cuts to his neck, were treated in hospital.
“I don’t know why [the gunman] could not fire, but I think it was because his gun was jammed,” said Mr Norman. “We were all enormously lucky.”
Mr Stone and Mr Skarlatos are members of the Air Force and the National Guard respectively.
Mr Stone has now been discharged from hospital and has joined his countrymen in Arras. They will all spend the evening at the US embassy in Paris.
US President Barack Obama has telephoned the three men to commend their “extraordinary bravery”.
US Secretary of Defence Ash Carter praised the three, saying that the two servicemen had shown why “on duty and off, ours is the finest fighting force the world has ever known”.
The 554 passengers included French actor Jean-Hugues Anglade, the star of Betty Blue and Nikita, who was lightly wounded breaking glass to sound the alarm.
In an interview with Paris Match magazine, Mr Anglade said train staff entered a private cabin and locked it when they heard gunshots, leaving the passengers alone.
“I thought it was the end, that we were going to die, that he was going to kill us all,” he said.
However Agnes Ogier, the boss of Thalys, denied Mr Anglade’s allegations, saying train staff “fulfilled their duties”.
One member of staff found himself under fire and took five or six passengers with him into the baggage car, where he sounded the alarm, she said.
French President Francois Hollande telephoned Mr Obama on Saturday to thank him for the “exemplary conduct” shown by the three US citizens.
British Prime Minister David Cameron also praised their “extraordinary courage”.
The American men and Mr Norman were awarded medals for bravery by authorities in Arras.
Anti-terror investigators in Paris now have 96 hours to question the suspect.
The suspect boarded the Thalys train in Brussels, and Belgian prosecutors also opened an anti-terror investigation on Saturday morning.
France has been on edge since the attack on the Charlie Hebdo magazine and a Jewish supermarket in Paris in January, which left 17 people dead.