Whip Whitaker had an epic layover in Orlando — an all-nighter with a sexy stewardess and much imbibing. A little sniff-sniff bump to get him going in the morning? It just gets the day going.

He puts on his uniform and shows up for work. He’s an airline pilot. Maybe a couple of bottles of the plane’s mini-vodkas to take the edge off the edge? Why not?

He dozes off in the cockpit, brushes off the “You feeling OK, Captain?” questions from the co-pilot. He’s an accident waiting to happen.

But when it does, nobody is cooler under pressure than Whip, given an aged, icy competence by Denzel Washington. He gets a doomed jetliner on the ground near Whip’s hometown of Atlanta with minimal loss of life. He’s a hero, right? Except for all that earlier stuff.

“Flight” is a terrific thriller about that crash — detailed to the nth degree — and a moving drama about “that earlier stuff.” Because what do you do with a case like this, a self-destructive alcoholic whose condition may have contributed to a tragedy, or mostly averted it?

Washington gives one of the great performances of his career in this fence-sitter of a film. “Forrest Gump” director Robert Zemeckis, returning from the “Polar Express”/ “Mars Needs Moms” toy store of motion-caption animation, and screenwriter John Gatins (“Coach Carter”) serve up a morally ambiguous morality tale that dares to suggest that maybe this guy’s condition was a good thing — in this case.

And it’s that rare movie that slaps the imprimatur of comic-cosmic cool on a drug dealer. John Goodman’s drinking-and-driving, pony-tailed swagger as Harling, Whip’s candyman, is hilarious and — dare I say it — heroic. He’s the first guy to visit Whip in the hospital, the first to offer “help,” the first with words of praise.

But Whip has dodged a bullet. Maybe he’s ready to get straight. But not without a little rationalizing.

“Without me up there, there would have been 102 funerals, and not six.”

One thread of the story concerns Whip trying to get a handle on what has happened, and to keep “reluctant hero” attached to his name, with the help of the head of his pilot’s union (Bruce Greenwood, always good) and the union’s lawyer (Don Cheadle, always great). They pitch in despite the gathering evidence to the contrary.

Another thread follows Whip’s new friend, Nicole (Kelly Reilly), a fellow junkie he met in the hospital, a damsel in distress whom he gallantly rescues, even though we wonder if he can even save himself.

Zemeckis and Gatins deftly weave those two threads together through some of the best-acted scenes you’ll see in a movie this year. James Badge Dale is splendid as a dying cancer patient who gives Whip and Nicole a little life perspective in a hospital stairwell cigarette break. Brian Geraghty makes a great impression as the frightened co-pilot who leans on his faith the way Whip does his cocaine.

Page 2 of 2 - And Tamara Tunie is dazzling as an older stewardess, a church-going Atlantan Whip relies on when the chips are down. She delivers the film’s most moving scenes, first in the cockpit, where Whip summons her as they’re about to crash. Remember the black box, he tells her.

“What’s your son’s name?”

“Trevor.”

“Say ‘I love you, Trevor.’”

But she and we see Whip’s dark side, the one he wants to hide, the one he’s anxious to get others to lie for him about. He’s arrogant, damaged, unfit for duty, for relationships, for life itself. Washington fearlessly makes this guy as unlikable as any character he’s ever played.

For all its many pleasures, “Flight” doesn’t quite justify or earn the conclusion served up here. It also straddles that moral fence a little too confidently for its own good.

Then there’s this clumsy habit Zemeckis has of underlining a perfectly clear, cogent scene with a redundant piece of music. A junkie shoots up? “Sweet Jane” on the soundtrack. A dope dealer struts into the scene? “Please allow me to introduce myself” wafts up, the Rolling Stones’ “Sympathy for the Devil.” The director who had a character say “I’m going to San Francisco” just as “If You’re Going to San Francisco” welled up on the “Forrest Gump” soundtrack needs to learn that just because you can afford the rights to an inanely obvious song doesn’t mean you have to actually use them.

Those quibbles aside, “Flight” still makes for a riveting character study, and a sometimes moving and sometimes amusingly amoral morality tale set in the vodka-and-coke friendly skies. And Washington puts another over-50 exclamation point on an already storied screen-acting career.