If you saw Paul Greengrass’ “United 93,” a terrifying depiction of one of the doomed flights on 9/11, you know this director can evoke a harrowing, real-life event like few others. So it’s no surprise that Greengrass has produced another expertly crafted, documentary-style film based on a real event — the 2009 hijacking of a cargo ship by Somali pirates and the five-day standoff that ensued, with the ship’s American captain, Richard Phillips, held captive in a stifling covered lifeboat after offering himself as a hostage.

A major difference is that this movie has a happy ending — for the captain, anyway, who was rescued in a dramatic high-seas Navy sniper operation.

Tom Hanks delivers some of his finest work here, playing the Everyman role he does so well, in this case a fairly ordinary guy forced by circumstance to be a hero. And yet “Captain Phillips” is a remarkably unsentimental film, with an emotional catharsis coming only at the very end. This is where Hanks digs deepest as an actor.

What Greengrass excels at is action — taut and visceral — and it happens as soon as the captain suddenly looks at a screen and sees two small dots moving toward the ship.

Two skiffs are carrying bands of armed men; from an early scene on a Somali beach, we know they’ve been whipped into action by their warlords. When they realize they’ve happened upon a U.S. ship, they can’t believe their luck.

What WE can’t believe is how a huge cargo ship is so vulnerable to small bands of armed men. But the Maersk Alabama has no gun power aboard, only huge hoses to repel pirates and their machine guns. They don’t work. Soon, four pirates have hoisted a ladder onto the ship. “I’m the captain now,” says their leader, Muse.

And the ordeal begins. Greengrass and cinematographer Barry Ackroyd are at their most effective in scenes like the frightening search by angry pirates hunting down the crew.

Things get even more intense in the lifeboat, where the pirates are locked in with Phillips for several agonizing days. With the U.S. Navy bearing down, it’s pretty clear where it’s all headed. The only question: Who will die?

The movie humanizes the pirates but is not inclined to forgive them. All four Somali actors are excellent, but especially Barkhad Abdi, memorable as Muse.

As for Hanks, his final moments are his best, as Phillips registers in an intensely personal way the cumulative effects of what he’s endured. It’s safe to say those moments will be what’s remembered most from this movie, and for a long time.

“Captain Phillips,” a Sony Pictures release, is rated PG-13 by the Motion Picture Association of America for “sustained intense sequences of menace, some violence with bloody images, and substance use.”