The incident happened on the high-speed Thalys service near Arras, and the attacker was arrested at Arras station.
President Barack Obama praised the passengers, who included two off-duty US military personnel.
The man arrested was a 26-year-old Moroccan. Anti-terrorist officers have taken over the case.
The gunman’s weapons were said to include a Kalashnikov, a knife, an automatic pistol and cartridges.
French authorities said three people were injured, two of them seriously – one with a gunshot wound, the other a knife wound.
France’s Interior Minister Bernard Cazeneuve said the attack took place at 17:45 local time on August 21.
French media said the arrested man was known to the intelligence services but he has so far refused to talk to police in Arras.
Two of the American men who overpowered the gunman, Spencer Stone and Alek Skarlatos, are members of the Air Force and the National Guard respectively.
Their friend, Anthony Sadler, was travelling with them and described the scene: “As he was cocking it to shoot it, Alek just yells, <<Spencer, go!>> And Spencer runs down the aisle.
“Spencer makes first contact, he tackles the guy, Alek wrestles the 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.”
Chris Norman, a British man living in France, was also hurt while trying to subdue the attacker.
“I came in at the end of it all and helped get him under control,” he said at a news conference in Arras.
“The guy pulled out a cutter and started cutting Spencer – he cut behind his neck and nearly cut his thumb off.”
Spencer Stone remains in hospital.
The passengers included French actor Jean-Hugues Anglade, the star of Betty Blue and Nikita, who was lightly wounded breaking glass to sound the alarm.
The American men and Chris Norman were awarded medals for bravery by authorities in Arras.
Minister Bernard Cazeneuve said the passengers were “particularly courageous and showed great bravery in very difficult circumstances”, adding: “Without their composure we could have been confronted with a terrible incident.”
“The president expressed his profound gratitude for the courage and quick thinking of several passengers, including US service members, who selflessly subdued the attacker,” the White House said in a statement.
“It is clear that their heroic actions may have prevented a far worse tragedy.”
Belgian PM Charles Michel called the incident a “terrorist attack”.
Images shared on social media appeared to show a man being restrained on the station platform in Arras.
One photograph showed an injured man in a blue top and jeans lying on the floor of the train.
French rail firm SNCF said there had been 554 people on board the train.
Thalys said several trains had been delayed in the wake of the attack.
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.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…