The three Americans — Airman First Class Spencer Stone, 23; Alek Skarlatos, 22, a specialist in the Oregon National Guard; and their friend Anthony Sadler, 23 — received the honor in the gilded halls of the Élysée Palace, where they were joined by Chris Norman, 62, a British consultant.

“One need only know that Ayoub El Khazzani was in possession of 300 rounds of ammunition and firearms to understand what we narrowly avoided, a tragedy, a massacre,” Mr. Hollande said at the ceremony, referring to the suspect in the attack, a Moroccan who is in police custody and denies that he had planned to stage a terrorist attack.

“Your heroism must be an example for many and a source of inspiration,” Mr. Hollande added. “Faced with the evil of terrorism, there is a good, that of humanity. You are the incarnation of that.”

After his speech, Mr. Hollande pinned the Legion of Honor medal on the three Americans, who wore khaki slacks and polo shirts, bringing a casual touch to the ornate ceremony. Airman Stone, whose thumb was severely cut by the gunman, still had his left arm in a sling as well as a bruised eye.

The three friends were on a tour of Europe that included stops in France, Germany, Italy, the Netherlands and Spain. They had intended to spend Friday night in Amsterdam but changed their minds and boarded a high-speed Thalys train to Paris. Shortly after the train crossed the Belgian border into France, they heard a shot, saw a gunman with an AK-47 and rushed to stop him.

A French citizen who was the first to tackle Mr. Khazzani but who has declined to be identified will receive the honor at a later date, as will Mark Moogalian, 51, a passenger with dual French and American citizenship who struggled with the attacker and is recovering from a bullet wound.

The courageous responses to the presence of a gunman drew attention and praise from around the world, especially in France, where many quickly encouraged Mr. Hollande to award the men the Legion of Honor, which was created by Napoleon Bonaparte in 1802 to reward “outstanding merit.” Several senior officials, including Prime Minister Manuel Valls and the head of the French rail company, attended the ceremony on Monday.

Mr. Norman, speaking in French to reporters after the ceremony, said he felt honored by the distinction. “I did what I had to do,” he said. “It wasn’t heroism, it was what needed to be done in a situation of survival.”

The three Americans did not speak publicly on Monday, but at a news conference on Sunday at the American ambassador’s residence, they brushed aside suggestions that they were heroes.

On Monday, the three grinned as they posed for photographs with Mr. Hollande and the American ambassador, Jane D. Hartley, on the steps of the Élysée Palace.

The upbeat mood will do little, however, to dispel growing unease in Europe about how to deal with new threats to targets like trains and how to monitor thousands of potential suspects, especially radical Islamist militants returning from Syria.

While only French citizens can be members of the Order of the Legion of Honor, foreigners can receive the medal, which has also been awarded to the novelist Toni Morrison and the actor Clint Eastwood. Airman Stone, Mr. Skarlatos, Mr. Sadler and Mr. Norman were made knights of the order, the lowest of five ranks.

Correction:Aug. 24, 2015

An earlier version of this article misstated the number of ranks in the Order of the Legion of Honor. There are five, not four.

Lilia Blaise and Elian Peltier contributed reporting.

Get news and analysis from Europe and around the world delivered to your inbox every day with the Today’s Headlines: European Morning newsletter. Sign up here.

A version of this article appears in print on , on Page A3 of the New York edition with the headline: France Honors Four for Actions Against Gunman on Train. Order Reprints | Today’s Paper | Subscribe