Three young Americans who are playing themselves in a Clint Eastwood-directed movie about how they foiled a terrorist attack in France say their actions were guided by God.

The 15:17 to Paris, which opens in the US and UK in early February, recounts the dramatic events of 21 August 2015 when the three friends launched themselves at a man carrying an automatic AK47 and other weapons on a crowded train.

The acclaimed actor-director asked the trio to play themselves in the movie, along with others involved in the incident. As well as focusing on the onboard action, the film tells the backstories of the childhood friends who were hailed as heroes.

On the day, Ayoub el-Khazzani, 25, a Moroccan national, allegedly launched the attack shortly after the train, with 500 passengers onboard, crossed into France en route from Brussels to Paris. As well as the assault rifle, he was armed with a pistol, a knife, a hammer and petrol.

Alerted by gunshots during an initial altercation with a passenger, Spencer Stone, then 23 and a medic in the US army, ran down the narrow aisle at Khazzani as the Moroccan lifted his AK47 and took aim. The assault rifle jammed.

Amid chaos and panic, Stone’s friends, Alek Skarlatos, 22, also in the US military, and Anthony Sadler, 23, a college student, joined in the fight. By the time Khazzani was overpowered with the help of a British passenger, Chris Norman, Stone had been stabbed several times in the neck; another passenger, Mark Moogalian, 51, had been shot and was bleeding profusely. Moogalian survived.

The friends, who were on a tour of Europe, were instant celebrities. They met President Barack Obama, were awarded medals by France, Belgium and the US, appeared on talkshows, and Skarlatos took part in Dancing With the Stars, the US version of Strictly Come Dancing. With the help of the author Jeffrey E Stern, they wrote a book, The 15:17 to Paris, now adapted for the big screen.

All three are practising Christians. They met in a Christian school in California and grew up attending church, and believe that their actions that day were part of God’s plan.

“We know this series of events weren’t coincidences. It’s like our lives were leading up to that moment,” Sadler, a pastor’s son, told the Guardian. “You don’t always know what plan God has for you. What we’ve come to realise with hindsight is that [this] was all part of a plan, of a bigger picture. That’s where we were supposed to be that day.”

According to Skarlatos, “if you look at the statistics of everything that happened, just the odds of being in a terrorist attack are astronomical. The odds of surviving it and being the ones that stopped it, and the odds of our exact situation happening to us, are too astronomical to believe that it was purely just chance. I really think God had a hand in it. We were vessels, being used.”

They were all “pretty frightened” at the time, said Stone. “It’s a pretty paralysing feeling – you look at a guy with a loaded, automatic AK47, and you think the only result is going to be your death. Running at him, we had no hope of actually making it to him. Yeah, we were all pretty scared that day.”

Skarlatos said: “It was act or die. There wasn’t any time to think about anything, because if you didn’t do anything, you’d end up dead. We just kind of went for it. We all thought we were going to die anyway; we were on a moving train with nowhere to go.”

The experience of playing themselves in the movie was “the funnest two months of our lives”, said Stone. Eastwood – who has made several action movies about real-life heroes – was relaxed and down to earth, making it easy for them to relive the incident.

They said they had a positive message to impart: everyone is capable of the extraordinary, and God has a plan for each of us.

“I think it’s our responsibility to take that message and be responsible with it and spread it as much as we can so we don’t waste the opportunity that [God] gave us,” said Sadler. “The fact that we’re living, we’re meant to spread the story and it’s meant to touch people, and we’re the three people that were chosen to do that.”

But they also had practical advice for anyone caught in a similar situation. “I would say if you can run, run. But we didn’t have the option to run,” said Sadler.

Not all those involved in the incident shared the trio’s faith in God. Moogalian, a French-American academic, who was bleeding heavily from a gunshot wound, was asked by Skarlatos if he wanted to pray. “He actually said no to me,” Skarlatos said.

Stone and Skarlatos have now left the military and Sadler has graduated from college. Making the movie has given them the “acting bug”, said Stone. “If we can make it a career, why not? So I think we’re all going to give that a shot.”

Khazzani is awaiting trial in France; two other men have been charged in Belgium in connection with the incident.