THE mob was rattling the gates, while inside the US embassy in Tehran the shredders were juddering and the staff were close to panic.

It was November 4, 1979, and the Iranian hostage crisis, one of the greatest post-war challenges to America's standing, was about to begin. Amazingly, six staff managed to escape. Even more amazing was what happened next.

The story, kept secret for almost 20 years, is told in Argo, a thriller directed by Ben Affleck and starring John Goodman, Alan Arkin, Bryan Cranston and Affleck.

The director of Gone Baby Gone and The Town was just seven at the time of the crisis and more interested in his Star Wars action figures. But when the script was sent to him, the adult Affleck knew a terrific story when he saw it.

The six Americans made it as far as the Canadian embassy, where the ambassador, Ken Taylor, kept them hidden. Since discovery was likely to lead to execution, an attempt had to be made to get them out. But how? Cue CIA officer Tony Mendez and an appeal to Hollywood that led to one of the most bizarre "exfiltration" schemes ever devised. Mendez would go in posing as a Canadian film-maker of a science-fiction film called Argo, and pretend the six were his crew.

After receiving the script, Affleck called George Clooney, one of the producers, and asked to do the film. Not only did Affleck get the job of directing, he hired himself to play Mendez. "The actor half of me saw this great part and wanted to do it, and since I was sleeping with the director I got it," he laughs.

Argo is a thriller with touches of comedy, and, crucially, a true story besides. Each element had to be weighed carefully.

"It's tricky. I have two responsibilities as a film-maker. One is to make the best movie I can possibly make, the other is to make it as truthful as I possibly can. It's not a documentary; it's a drama, but absolutely the spine of the story – what's presented here – is true."

Among those helping to keep it real was the real Mendez. Affleck was keen to instil in the actors playing the "houseguests" a tiny sense of what it must have been like to share a small space with each other. So he sequestered them for a week, Big Brother-style, took away all gizmos, and instead gave them newspapers, music and games from the period.

"To my disappointment they all got along very well," says Affleck. There were complaints, though. One wanted to bring his yoga mat, and took exception to Affleck's assertion that there was no yoga in 1979, or at least not for 48-year-old State Department employees called Bob. "I had to peel the yoga mat out of his hands," he says.

Then there were the mobile phones. "Ultimately we had to have a PA stationed outside the house with their phones in case an emergency call came in. But then the definition of what constituted an emergency started shifting. Your girlfriend calling didn't make it an emergency. But at the end, after the initial griping, they loved it and said it really helped."

This is Affleck's third feature as a director. That the kid who won an Oscar, with Matt Damon, for his screenplay for Good Will Hunting should become a director of note shouldn't have been that surprising. Yet there were those awkward in-between years for Affleck – the Gigli and the Pearl Harbor years, being one half of a celebrity couple with Jennifer Lopez – that left some wondering if he had what it took to make a lasting career in movies.

Today, the Affleck that arrives at the London Film Festival to talk about Argo is a 40-year-old father of three (his wife is the actor Jennifer Garner) clad in a tweed sports jacket, shirt and jeans. The successful Hollywood director in repose.

It was always his ambition to direct, even if he coughs to helming some "very bad" student films in his youth. He doesn't mention it by name, but his 1993 short I Killed My Lesbian Wife, Hung Her on a Meat Hook, and Now I Have a Three-Picture Deal at Disney has to be in any hall of shame.

In 2007, however, along came Gone Baby Gone, the Affleck-directed adaptation of Dennis Lehane's novel, which starred Ben's brother Casey in the lead. Toasty reviews for that were followed by others for 2010's bank job thriller The Town.

"Probably the smartest thing I've ever done was to use my acting career as a free film school, because they can't kick you off the set for asking questions if you are actually in the movie. So that's what I did. I consider myself a film-maker, actor, writer, producer – I don't see stark delineations between those; I feel like they're all part of the same soup of making a movie."

It was important for Affleck that the story of the Iranian hostages should be put in context, which is why the film explains the state of play between Iran and the US at the time of the revolution.

"I'm not trying to lead the audience to any particular kind of judgment. I'm simply trying to tell the story and allow people to draw their own conclusions. I think that's better film-making and probably more ethically responsible film-making."

Given recent events in Libya, where a US consulate was stormed and four people killed, it is a sensitive time to be revisiting what happened in Iran. But Affleck doesn't want the film to be seen as a political statement: "This is about factual events that took place 30 years ago and we obviously had no way of anticipating the ways in which history would repeat itself." That said, he is proud the movie pays homage to foreign service staff who serve in dangerous places.

The film was shot in Los Angeles, Washington DC and Istanbul. Affleck wanted to got to Iran but was advised by the State Department that any visit would likely be used by the Tehran regime for its own political purposes. He also tried to get Iranian film-makers he knew to film some material.

"Even those folks were too scared to do that, which kind of spoke to me about how oppressive the regime is there, which was really very sad, particularly given how many great Iranian film-makers are there. Look no further than A Separation," he says.

The solution to finding actors of Iranian origin lay in – where else? – Los Angeles. With half a million Persians in LA, most of whom left after the revolution, the area has been dubbed "Tehrangeles". When Affleck issued a casting call, "a mountain" of people turned up.

Among the films in which he will next be seen is Terrence Malick's drama To the Wonder. As an eternal film-making student, Affleck was keen to study the Hollywood living legend at work. "One of the valuable things I've learned is that he's not making his movies for anyone but himself," he says.

Affleck also met celebrated costume designer Jacqueline West on To the Wonder – and immediately hired her to work on Argo. The eternal film-making student is always learning.

Argo opens on November 7.