Three men who helped disarming an attacker on a train from Amsterdam to France, Anthony Sadler (l.) Alek Skarlatos (c.) and Chris Norman, a British man living in France, pose with medals they received for their bravery at a restaurant in Arras, France on August 22, 2015.

Three Americans were on a train from Amsterdam to Paris on Friday when an armed man started attacking passengers, and they were fast to react.

The incident happened when a French passenger tried to enter a toilet on the train and he encountered the gunman. French Interior Minister Bernard Cazeneuve said in a press conference Friday that the passenger tried to overpower the gunman and his gun fired.

Spencer Stone, member of the US Air Force stationed in Portugal, Alek Skarlatos, an Army National guardsman stationed in Afghanistan, and their American friend Anthony Sadler, who was visiting Europe for the first time, were on the high-speed Thalys train bound for Paris when they heard gunshots in the carriage behind them, Mr. Sadler told ABC News.

"Alek just yells, 'Spencer go!' and Spencer just gets up within five seconds of the guy being in the car and just rushes back there," said Sadler. "He gets up, I get up and Alek gets up and all three of us just rush back there."

They quickly tackled him. "The three of us beat up the guy," Sadler told CNN. "In the process, Spencer gets slashed multiple times by the box cutter, and Alek takes the AK away."

A British man, Chris Norman, was also in the same train carriage and helped to restrain the attacker after he was tackled.

Mr. Skarlatos told Sky News, everybody started beating the gunman while Stone held him in a chokehold until he went unconscious.

Mr. Cazeneuve identified the gunman as a 26-year-old Moroccan national who lived in Spain until 2014, and in Belgium this year, BBC reported. Spanish intelligence passed on information about the suspect to France in February 2014, he added.

A European counterterrorism official said the attacker was on the radar screen of European counterterrorism agencies for his radical jihadist views, CNN reported, while another security source said French intelligence knew the suspect who appeared to be sympathetic to ISIS. A full determination on his motive and loyalties is not known yet.

During the incident three people were injured, including Stone who was hospitalized and French actor Jean-Hugues Anglade.

Mr. Anglade told Paris Match: "We heard passengers shouting in English, 'He's firing, he's firing. He has a Kalashnikov.'" He said he saw train personnel running down the corridor to take refuge in their work car, and claimed they locked the door and refused to answer desperate knocks.

"We were in a bad spot but with good people," Anglade said. "We were incredibly lucky to have American soldiers with us. I pay homage to their heroic courage and thank them. Without them, we all would be dead."

After the attack the train was rerouted to Arras, 115 miles north of Paris, where the suspect was taken into custody.

The American men and Mr. Norman were awarded medals for bravery by authorities in Arras. French President Francois Hollande has thanked three American men for overpowering the gunman. He is going to meet the American and other citizens who helped subdue the gunman, his office said in a statement Saturday.