Sometimes a felicitous film seems more a natural occurrence, half magic and half accident, than a deliberate product. By most accounts, “Casablanca” is an example of this. But there are times when you simply know a master’s hand is at work. In the case of “The 15:17 to Paris,” that hand belongs to director Clint Eastwood.

The film is based on the events of August 21, 2015, when three Americans touring Europe, two of them soldiers on leave and all of them childhood friends, overcame an Islamic terrorist attacker, Moroccan Ayoub El-Khazzani, who boarded a high-speed train to Paris armed with a sack of deadly weapons. El-Khazzani was equipped with an AK-47, an automatic pistol, a box cutter, and hundreds of rounds of ammunition.

Imagine being trapped, weaponless, on a speeding train while an Islamic terrorist makes his way down the aisle with a machine gun. In stopping the terrorist, the three men, Spencer Stone, Alek Skarlatos, and Anthony Sadler, along with the passengers who aided them, likely prevented a horrific bloodbath and dozens of murders.

There was one causality that day. Dual-citizen French-American Mark Moogalian, heroic in his own right, yanked the machine gun from the hands of El-Khazzani, then was shot in the back of the neck by El-Khazzani with a pistol as he tried to move away. He dropped the gun, and the jihadist picked it back up. It was then that Stone charged El-Khazzani. After overcoming the terrorist with the aid of Skarlatos and Sadler, Stone behaved with cool-minded heroics and stopped the blood flow from Moogalian’s neck artery. It was a bravura performance of courage and competence.

Meanwhile Skarlatos and Sadler, with the help of British businessman Chris Norman, secured the terrorist and his weapons. The three Americans reacted as a unit, forged in friendship. It is clear that, even with Stone leading the charge, it was teamwork that stopped El-Khazzani cold in his tracks, thus saving many lives.

These raw events from that day in 2015 are the foundation Eastwood begins with. There is also a given that the memory of the events is relatively fresh in the minds of many audience members. Obviously, one could hire actors and tell the story in a conventional manner. One could also make a documentary. Eastwood does a little of both, and it proves an inspired choice.

First, he makes the perhaps surprising decision to use the men themselves as his actors. Ordinarily, this might be disastrous. Acting is not easy. As a man who married an actress, I can attest to my wife’s skill and commitment to developing her craft. My own cavalier attitude toward the craft changed when she challenged me to take classes from one of her mentors, the great Ed Morehouse, who taught for many years at HB Studios in Manhattan. It was humbling, and I’ve never bad-mouthed the actor’s trade since.

Eastwood, of course, knows this very well. But he must also have been aware of how fresh the images of these young men are to many of us. Then there is the fact that these are three fairly good-looking dudes in real life. So Eastwood went with the real guys. There is precedent for such a stunt. For instance, Medal of Honor winner Audie Murphy plays himself in the uneven, but watchable 1955 biopic, “To Hell and Back.” Of course, Murphy had appeared in numerous films before “To Hell and Back,” including John Huston’s “The Red Badge of Courage.”

Eastwood’s decision to use the guys mostly pays off, although there are trade-offs. The dialogue is wooden. A good part of it seems to be either improvised, or taken directly from the prose of the book the men wrote (with Jeffrey Stern) about the incident. This is particularly evident in the static scenes of character and backstory development. Stone and Skarlatos and Sadler’s sports talk seems canned. But by letting the men use their own words, Eastwood coaxes natural delivery and realistic, unstilted physical action from them.

Meanwhile, Eastwood uses flashbacks that add nuance and context to a climax that occurs quickly in real time. For instance, we learn that, while Stone’s courage seemed to be present from the get-go, his competence was hard-won and a long time coming.

It seems all three boys had problems fitting in as they were growing up, and were often in trouble with teachers and administrators. The children playing the three in middle school, William Jennings, Bryce Gheisar, and Mikél Williams, do a serviceable job, especially Jennings as young Spencer. In fact, the three middle school amigos came together as the odd-men-out while visiting the principal’s office of their Christian academy.

The faculty of the school do not come off at all well. Their mothers, on the other hand, come across as faithful, godly, protective of their sons, and quite heroic. Played by actresses Judy Greer and Jenna Fischer in the movie, they are the sources from which the courage their sons later display likely originated.

This flashback sets up the key scene in the film. After graduation from high school, Stone has let himself go physically, and is leading a bit of a directionless life. He and Sadler are sitting around watching a game, when Stone informs Sadler that he plans to join the Air Force and become part of a specialized para-rescue unit. He has told Skarlatos as well, and is surprised when neither friend reacts strongly to the news. Sadler then nonchalantly delivers his verdict on Stone’s chances. “It’s not that we think you can’t do it. We just don’t think you will.”

Instead of whining or falling into depression after this epic putdown by a buddy who incontrovertibly knows him well, Stone decides to change things. He drops forty pounds. He gets into excellent physical shape. But all, it seems, is to no avail when he does not quality for Air Force Para-rescue due to his lack of depth perception, something he cannot fix by hard work. When he subsequently washes out of Air Force SERE training, it seems the old problems from middle school have returned to drag him down. Perhaps Spencer Stone was born to fail.

Yet Eastwood carefully chronicles the incremental improvements and hints of the fortitude and competence Stone is developing because of his repeated disappointments. After a blown treatment attempt on a first-aid dummy, we watch as Stone asks the right questions and learns how to correctly treat traumatic bleeding. We see an instructor talk him through how to apply a proper jujitsu hold to the neck to knock out an opponent — and we see that, though frustrated and initially clumsy at it, Stone does not give up until he has the technique figured out.

The story is told in flashbacks from two points in time: as El-Khazzani’s attack unfolds, and from various points in the European travels of the three men leading up to their boarding Thalys number 9364 to Paris together on that fateful August day. Ray Corasani does a scarily good job of depicting El-Khazzani, and the passengers on the train, including Moogalian and Norman, are mostly played by the real people who were there. It’s a fascinating bit of meta-realism that Eastwood keeps from appearing staged and overly sentimental by the sheer immediacy of its depiction.

Because he used Stone, Skarlatos, and Sadler as themselves, Eastwood is able to deliver a moving denouement. The film shows the actual footage of French president Francois Hollande presenting the actual men with their actual Légion d’honneur medals. In this unique moment, Eastwood’s decision to go with the men in the lead roles feels totally justified.

“The 15:17 to Paris” is a worthy and unusual piece of filmmaking, a careful blend of biopic and documentary. At one hour and thirty-four minutes, it is just the right length. The storytelling technique works, and the movie manages to create exciting and emotional moments, both because of the freshness in the audience’s mind of the events it portrays, and due to Eastwood’s consummate storytelling skill. Perhaps in ten or twenty years, the film will have lost the power of immediacy and seem a historical oddity and not really a flick still worth watching by a general audience. But for now, it delivers on both counts.