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.
The US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…