© Gordon Welters for The New York Times Airman First Class Spencer Stone has been recuperating at Ramstein Air Base in Germany. Airman First Class Spencer Stone’s summer vacation in Europe did not begin well.

There he was in Lisbon, the first stop of what was to be a three-week trip with two childhood friends, and he felt like a vagrant. A medic at Lajes Air Base in the Azores, he had missed the last train to Rome and so spent the night with his head propped against a concrete pillar next to a closed-up shop outside the Lisbon airport terminal, hugging his backpack to himself.

The next day he managed to catch a flight to Italy to begin the trip of a lifetime, but not in the way he ever imagined. By the time it was over, Airman Stone and his two friends — Alek Skarlatos, a specialist in the Oregon National Guard, and Anthony Sadler, a senior at California State University, Sacramento — had foiled a terrorist attack, saved a trainload of people and received the French Legion of Honor.

Airman Stone, who is to arrive back in the United States on Thursday, survived a stabbing in the neck. President Obama personally praised the friends’ bravery; President François Hollande of France said they had given the world “a lesson in courage, in will, and thus in hope.”

But before the hero’s welcome, the international acclaim, and the Jason Bourne-like maneuvers, Airman Stone spent the first week of the trip straight out of the pages of Let’s Go Europe. As he recounted in a telephone interview on Wednesday from Ramstein Air Base in Germany, he wandered the cobblestone streets of ancient Rome — his first visit to the city — enjoyed Piazza San Marco and a gondola ride in Venice, bicycled through Berlin and sampled the nighttime watering holes of Amsterdam.

On the morning of Friday, Aug. 21, Airman Stone and his two friends, a little hung over, headed to Amsterdam’s Central Station for a train to France. “We only planned to stay a day in Paris,” he recalled. “We thought, let’s just see the Eiffel Tower and then go to Barcelona.”

© Gordon Welters for The New York Times Airman First Class Spencer Stone, who helped disarm a terrorist and save a wounded train passenger. A little after 3 p.m., they boarded the train.

They had first-class tickets but found a compartment that looked good, so they took it over, figuring they would move if the real seat-owners arrived. Social media addicts, they settled down to Facebook and Snapchat, posting their vacation photos. A family came along and the compartment got crowded, so they wandered off to their real seats. Airman Stone had some wine and a sandwich. He and Mr. Sadler both fell asleep to the rocking motion of the train.

Shortly after the train crossed the Belgian border into France, the sound of a gunshot abruptly awakened Airman Stone, who opened his eyes to see a conductor rushing down the aisle. Mr. Sadler woke up, too. Specialist Skarlatos, next to Airman Stone, turned around to look behind him. Airman Stone turned too, and saw a shirtless man standing in the aisle, cocking an AK-47. People were screaming.

“Let’s go,” Specialist Skarlatos urged, and Airman Stone, in the aisle seat, took off at a sprint toward the gunman. His two friends ran behind him.

“It felt like it took forever to get to him,” Airman Stone recalled. He could not figure out why he had not been shot yet. He said he kept expecting to feel a bullet rip into his torso.

“He’s about to shoot me,” he thought as the gunman, identified by the French authorities as Ayoub El Khazzani, pointed the rifle at him. “Why am I not dead yet?”

Airman Stone dived to tackle Mr. Khazzani, hit him in the torso and then fell on top of him. There was a desperate fight for the AK-47. Airman Stone put Mr. Khazzani into a chokehold, but still he fought back. Specialist Skarlatos got the rifle away from him, but Mr. Khazzani pulled out a handgun, cocked it, and pointed it at close range at Airman Stone. It clicked, but did not go off. Specialist Skarlatos pried the gun away, and Mr. Khazzani pulled out a box cutter.

“He’s got a knife! He’s got a knife!” Airman Stone yelled. With the box cutter, Mr. Khazzani stabbed Airman Stone in the neck and sliced his thumb to the bone as the two fought. Airman Stone was bleeding heavily now, from his neck and his thumb.

Finally, the three friends got control of Mr. Khazzani and punched him until he passed out. But the ordeal was not over. Specialist Skarlatos noticed a passenger, Mark Moogalian, falling over, apparently from a bullet wound to his neck. Blood poured out.

“I’m a medic!” Airman Stone screamed, crawling over to Mr. Moogalian. He thought to stem the bleeding with his shirt, but then realized the bullet had hit an artery. “So I laid him down and plugged my finger into his neck and the bleeding stopped,” he said. “That told me, no, I won’t be moving from this position.”

The friends called Mr. Moogalian’s wife over to talk to him and keep him calm as the train traveled 15 more minutes to Arras. There, paramedics boarded and told Airman Stone to step away from Mr. Moogalian so they could take care of both men. Airman Stone refused, yelling, “No, neck, got to stick your finger in!” The paramedic did, and Airman Stone was finally led off the train and taken to the hospital.

In Sacramento, Airman Stone’s mother, Joyce Eskel, got a phone call from Specialist Skarlatos’s mother and another from the Air Force. Her son and his two friends, Ms. Eskel was told, had thwarted a terrorist attack. Her son had been “cut.” He was hospitalized but would be O.K.

“I need to talk to him,” she blurted out. “He’s not answering my texts.” The French authorities had Airman Stone’s cellphone.

Ms. Eskel, who also spoke in the telephone interview from Ramstein, where she was visiting her son, said she turned on the television, shaking. One report said two men had been critically injured, one shot in the neck. She said she frantically wondered why they were saying he was critically injured when the Air Force said he was going to be all right.

At the hospital, a local woman came into Airman Stone’s room to help him eat. He could not use his hands, so she cut up his meat, and took care of him as a mother would.

Airman Stone started calling her his French mother, but he needed to talk to his real one. His French mother handed him her cellphone.

In Sacramento, Ms. Eskel picked it up on the first ring. By now she was terrified.

“Mom,” her son said, “don’t freak out, O.K.? I’m O.K.”

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.