Captain Phillips is a strikingly powerful movie, with a commanding lead performance by Tom Hanks that's easily the best work he's done in a decade. But for all its strengths, the film's best scene (and the scene that might earn Hanks an Oscar) comes at the very end of the movie — and it wasn't even in the script.

(Spoilers for Captain Phillips to follow.)

Most directors would probably have ended the film with Phillips being escorted to safety on the USS Bainbridge — or flashed forward, to show Phillips' homecoming with his wife and children in the United States. Instead, the film follows Phillips as his rescuers lead him to the ship's infirmary. Phillips is covered in blood, disoriented, and near-delirious with shock, and a medical examiner gently attempts to calm him down as he asks about his family between sobs.

The scene is extraordinarily raw — surprising, heartbreaking, and human in a way that few recent films have achieved. But how did it come about? In a press conference following a screening at the New York Film Festival, Hanks — who called the scene "a moment like I've never had making films" — revealed that the scene was entirely unscripted and unplanned. "It's not on the page at all," explained Hanks. "It was not meant to be the last scene in the film." Here is Hanks' full explanation of how it came about:

But we had the actual captain of the [USS Bainbridge] with us when we were shooting, and [director Paul Greengrass] said, 'What did you do with Captain Phillips when you first got him onboard?' And the captain said, 'Well, he was a mess, so the first thing we did was take him to the infirmary to get him cleaned up.' And Paul said, 'Well, why don't we go down to the infirmary?'

We'd never been there. It was not part of it. It wasn't in the schedule. It hadn't been scouted. It wasn't lit. But we went down there — and we had the actual crew of the ship that we were shooting on — and said, 'What would you do to someone that came in here?' And they said, 'Well, we'd lay them down here, and we'd do this and this and this.' Paul said, 'Well, shall we give a try?' And Barry said, 'Well, give me a couple minutes to put up some lights.' We shot it — I don't know, four or five times, I guess.

We had, literally, the crew of the infirmary. They didn't know they were going to be in a movie that day. They thought they might be dress extras walking around in the background, and here they are — boom — with cameras that are going to be on them.

The first take I remember completely falling apart because these people had never been in a movie before, and they could not get past the horrible self-consciousness of everything that was going on around them. But we just stopped, and Paul said, 'Don't worry about it. You can't do anything wrong. It's not a test. If it doesn't work, we won't use it. So let's just try it again and see what happens.' At that point, those people were really quite amazing. The freedom in order to give it a shot was so liberating. And everybody was up for it. So it really made itself.

Paul Greengrass, however, refused to let Hanks be so modest:

When we went down to the infirmary, and we tried that first go, and Barry got in the wrong place — you're sort of trying to do it all in a rush. And it wasn't quite working, but you could feel something. I remember we went outside, and I said, 'Did you feel something there?' And [Tom] said, 'Yeah, yeah, I did. It's just… Everybody's being nice to me, after 60 weeks of people putting guns in my face.' What I mean is… What that is — and you see it with great actors, of which Tom obviously is one — where you see a door. There's just a tiny gap, but the door is there. And it takes courage to walk through, as an actor, and find the truth. And that's what is there in that scene. It's the truth of vulnerability, of shock, of confusion — all the things you would expect of things like that. But I think — and you've just seen it — whenever I see that scene, there's a shocking sense of humanity. And that is an actor finding the truth. You have to seize those moments, and Tom did.