“The idea came from desperation,” says Tony Mendez, a retired C.I.A. officer and the real-life inspiration for the character played by Ben Affleck in the coming movie “Argo.” As the head of the C.I.A.’s deceptively boring-sounding Graphics and Authentication Division, Mendez was responsible for foreign agents and their cover stories — which is why he was called upon in 1979 to construct a plan to evacuate six U.S. diplomats hiding at the Tehran homes of two Canadian diplomats.

As Mendez struggled to concoct a believable cover story with which to extricate the Americans, his wife at that time had a suggestion: What if we fake the death of the shah of Iran, who the revolutionaries were demanding return to Iran for a trial? Mendez dismissed it. “That would make a nice script for a movie,” he now recalls saying at the time, “but it doesn’t have much bearing on what we’re trying to do here.”

But the word “movie” stuck in his head. He decided he would have the diplomats pose as a Canadian film crew allied with a (nonexistent) sci-fi B-movie called “Argo.” That’s how he ended up working with John Chambers, a Hollywood makeup artist who famously gave Spock pointy ears. They opened a real production office in Los Angeles and promoted the fake film — after which Mendez flew to Tehran to escort the diplomats out. (He denies reports he did so with a fake nose but said he had “certain appliances I was using.”)

Now the fake-movie scheme (the details of which were declassified in 1997) has inspired a real movie. Mendez lives in rural Maryland, where we tracked him down to ask another question: Why call your fake film “Argo”? “It happened to be the punch line to a knock-knock joke we’d tell,” Mendez said. The joke opens: “A drunk comes along and tells a knock-knock joke. Knock-knock. Who’s there? Argo. Argo who?” The punch line begins “Arr, go . . .” but is not printable here. It does show up, in altered form, in the new film.