Tony Mendez, the real CIA spy in Argo

Tony Mendez now and then (left and centre) and played by Ben Affleck

Argo, a film about the audacious rescue of six Americans hiding in Tehran after the storming of the US embassy in November 1979, is the bookies' favourite for best picture at the Oscars. CIA agent Tony Mendez, played in the film by Ben Affleck, explains how the rescue plan was hatched.

Spoiler alert: key plot details are revealed below

The six Americans in hiding had escaped from the back door of the embassy as Iranian revolutionaries broke their way in, and taken refuge in the home of the Canadian ambassador. But they were at risk of being discovered, either by Iranian revolutionaries or the international media.

Much of the world's attention was focused on the several dozen embassy staff held hostage by Iran's new revolutionary regime. Of the 66 seized, 13 had been released after a fortnight. But US President Jimmy Carter was under pressure to secure the safe return of all the hostages - including those the Iranians were unaware of.

Image caption Argo is a major contender for Oscar success

Tony Mendez had to find a way of smuggling the six out of the country, but first he had to get himself in without giving rise to suspicion.

"We were looking for reasons for being in Tehran, but there were no good reasons," the 73-year-old former CIA chief of disguise explains.

"Normally we make a cover that is very boring, very forgettable. But we couldn't go as teachers as the international schools were closed. We couldn't go as oil technicians. We couldn't go as nutritionists pretending to be inspecting crops."

The Iranian hostage crisis

Image caption On 1 February 1979, Ayatollah Khomeini returned to Iran after 14 years in exile. An Islamic Republic was declared two months later and US citizens living in the country became targets.
Image caption On 4 November 1979, revolutionary students stormed the US embassy in Tehran, taking 66 hostages and demanding the return of the deposed Shah to face trial.
Image caption After two weeks, Ayatollah Khomeini ordered the release of 13 female and black hostages, but the release of all remaining captives became a priority for President Jimmy Carter.
Image caption On 11 April 1980, Carter approved a high-risk rescue operation, which resulted in the death of eight US personnel. After lengthy negotiations, they were finally released on 20 January 1981 - the day of Ronald Reagan's inauguration.

Mendez also had to consider that - unlike him - the six hostages had no training in clandestine affairs.

He was in Ottawa, liaising with the Canadian government, when he decided to "reverse the rules and create a distraction".

His plan was to travel to Tehran and pretend to be part of a location scouting team working on a science fiction movie.

"Everyone knows that people from Hollywood go where they want to go, never mind the time in history. They forget about the fact that there is politics and danger in the world," Mendez says.

In January 1980, he flew to Los Angeles with $10,000 in his pocket. The CIA had a long history of working with Hollywood, especially when it came to developing disguises.

He hired a script-writer, who started work immediately, and found office space for his fake production company Studio 6 - named after the six people he was planning to rescue.

Within two days a script was drawn up for a new production, called Argo. The storyline was similar to the science fiction trilogy Star Wars - a big box office hit at the time - and set in an unspecified mythical place with an exotic bazaar.

Studio 6 contacted magazines such as Hollywood Reporter and Variety to generate media buzz about the upcoming film. Mendez wanted it to sound as credible as possible in case the Iranian regime carried out background checks.

It had taken several weeks for Mendez to convince his superiors at the CIA and members of the Canadian and American governments to approve his plan. There was concern about the unpredictable situation on the ground, and long discussions about whether the hostages should be issued fake American, Canadian or altogether different foreign passports.

Failure would have been hugely embarrassing for the governments, and dangerous for the six hostages.

"There was no plan B for the operation. Usually there is an escape plan, but there would be no car sitting outside with the engine running," says Mendez. It was a "hairy" mission, as he puts it.

When he was finally ready to travel to Tehran, not even his wife Jonna Mendez, a CIA employee herself, knew what he was embarking on.

President Carter had been briefed, and sent Mendez a special note: "Good luck" - though it is highly unusual for a president to be in direct contact with CIA agents, Mendez says.

When he arrived, Tehran "was like a free for all", he recalls.

"At night the Revolutionary Guards amused themselves by driving up and down the streets and firing machine guns at buildings.

"The Revolutionaries had suspended all conventions."

Being identified as a US citizen on the streets of Tehran at this time was risky.

But when Mendez and his colleague Julio, a Farsi speaker, lost their way and asked a member of the Revolutionary Guard for directions to the Canadian embassy, they were lucky. He puts it down to the exotic cover story. "We were from Hollywood. We were more exciting than anybody else."

On Friday, 25 January 1980, Mendez and his colleague finally met the US embassy staff at the Canadian residence in Tehran, where they had been in hiding for 86 days.

"They were getting worried," he says.

He briefed them on the plan, and gave them Studio 6 business cards and clothes to make them look more Hollywood.

The Canadian government had agreed to fake Canadian passports for the group, and Mendez had brought maple leaf badges to attach to their suitcases and bags.

The next 48 hours were spent practising hostile interrogation techniques.

Everyone knew the escape plan was dangerous, Mendez remembers.

"The Iranians could have decided to behead us. Or we could have been dragged around with a jeep. All these things were possible," he says.

To get them to relax, he tried to make a game out of the preparations.

"I was hoping that [this way] they would loosen up and enjoy the operation. It may sound contrived, but you can distract people with fun much easier than with fear. With one of the guests I had to resort to liqueur - Cointreau - to jolly him along.

On Monday 28 January, the group headed to Tehran airport to catch the 07:00 flight to Zurich.

"There were times as we went through the checkpoints when we were not sure whether we would make it," Mendez says.

He and his colleagues had decided to book Swissair, the airline he regarded to be the most efficient and reliable, and based on intelligence information about staffing at the airport, the group was booked on an early morning flight.

Mendez hoped that by arriving at dawn, sleepy immigration officials and revolutionaries would be too tired to pay much attention to the group - and it worked.

The plane took off, and on arrival at Zurich airport, the six Americans were escorted away by State Department officials.

"There was no time for thank yous, so Julio and I went for lunch," Mendez says simply.

In March 1980, after a personal meeting with President Carter in the Oval Office, the CIA presented Mendez with an award - the Intelligence Star - but as the mission was classified, he was obliged to return it immediately. Not even his family could attend the ceremony.

For 17 years, the operation remained a secret, too sensitive to even be printed in the internal CIA magazine, Studies in Intelligence.

In the end, it was George Tenet, director of the CIA from 1997 to 2004, who encouraged Mendez to share the story of the daring operation - and it became the inspiration for the real Hollywood movie, Argo.

Ben Affleck, who directed the thriller and plays Mendez in the film, met the former CIA agent and his wife several times to consult them.

"We were showing him around. Our son Toby was our driver, and we took him to the CIA and some other places where spies hang out."

Two members of the Mendez family were extras, playing passengers in a car when the fictional Tony Mendez is at the airport on his way to Europe.

But despite the close consultation, Affleck managed to surprise the couple when they attended the premiere of Argo with the six former hostages.

"In the titles we noticed that Ben had dedicated the film to our late son Ian," Mendez says. "He used pictures of Ian in the film as well. Ben was very sensitive about it."

Both Jonna and Tony say they were touched by Affleck's tribute to Ian, who died of cancer, and whom Affleck never met.

"Ben is a lot more than a Hollywood guy. He is genuine and a sensitive father. It has been a joy to be associated with the film."

Tony Mendez spoke to World Update on the BBC World Service

You can follow the Magazine on Twitter and on Facebook