Ken Taylor, former Canadian ambassador to Iran, who kept Americans hidden at his residence during the 1979 Iran hostage crisis, in 2013. (Nathan Denette/AP)

Ken Taylor, the Canadian diplomat who gave shelter to six U.S. officials during the Iran hostage crisis in 1979 and 1980 and helped plan a daring high-stakes escape called the “Canadian caper,” which was depicted in the Oscar-winning film “Argo,” died Oct. 15 at a hospital in New York. He was 81.

He had colon cancer, his wife, Pat Taylor, said.

As Canada’s ambassador to Iran, Mr. Taylor quietly concealed the Americans in official diplomatic residences for 79 days until they could escape through an elaborate CIA-coordinated ruse.

Mr. Taylor arranged to provide false passports and other documents to the six Americans, who posed as Canadian filmmakers scouting locations in Iran for a science-fiction thriller called “Argo.” To test Iranian security procedures, he sent members of his embassy staff members on needless flights out of the Tehran airport.

When the Hollywood movie “Argo,” directed by Ben Affleck, appeared in 2012, many Canadians were upset that Mr. Taylor’s pivotal role in the scheme appeared to have been slighted. The film, which won an Academy Award for Best Picture, revolved around CIA officer Tony Mendez, played by Affleck, who was a master of forgery and disguise.

Ken Taylor, Canadian ambassador to Iran, speaks to reporters in Paris, Jan. 31, 1980. (AP/AP)

“Ben Affleck’s character was only in Tehran a day and a half,” Jimmy Carter, who was president during the crisis, told CNN in 2013. “The main hero, in my opinion, was Ken Taylor . . . who orchestrated the entire process.”

When Mr. Taylor went to Iran in 1977 as ambassador, Shah Mohammad Reza Pahlavi was still in power as the country’s leader. Over the next year, unrest grew as opposition to the shah coalesced around an exiled Muslim cleric, Ayatollah Ruhollah Khomeini. The shah and his family were forced to flee Iran in January 1979.

On Nov. 4, 1979, a group of Iranian students seized the U.S. Embassy in Tehran, taking more than 60 hostages. Several were released, but 52 others were held captive for 444 days until they were set free the same day Ronald Reagan was inaugurated as president in January 1981.

The hostage takers did not immediately realize in 1979 that four Americans who worked at the U.S. consulate, plus two of their wives, had found sanctuary at the Canadian Embassy. They were hidden in Mr. Taylor’s official residence and at the home of another Canadian diplomatic official, John Sheardown.

Mr. Taylor often had dinner with his clandestine house guests, who spent much their time playing Scrabble and reading.

“I’d nominate any one of them for the world Scrabble championship,” Mr. Taylor said in 1980. “They are also probably the six best-read Foreign Service officers.”

The Canadians explored various ways of spiriting the U.S. citizens out of Iran but decided it was too risky to drive through the countryside and drop them across the border. In time, Mendez and the CIA devised the “Argo” plan, but it was left to Mr. Taylor and the Canadians to pull it off.

Each of the six Americans would need impeccable Canadian documents and cover stories. Mr. Taylor obtained special permission to create Canadian passports, under false names, and to arrange for business cards, academic records and credit cards from Canada.

“It was an intricate operation,” Mr. Taylor told the Calgary Herald in 2013. “We received some help from the CIA. But, quite honestly, it was a Canadian-based and ­Canadian-executed operation.”

A Canadian diplomat who could read Farsi noticed that the dates on the passports were based on an older calendar no longer sanctioned by the new Iranian regime. The dates were altered at the embassy.

On Jan. 28, 1980 — it was still Jan. 27 in North America — Mr. Taylor sent two embassy officials to the Tehran airport. They called the ambassador, telling him the plan could proceed.

Mendez led the six Americans through five checkpoints without incident. At the sixth, an Iranian official took the fake passports into a separate room. After examining the documents at length, he returned them to the putative Canadians, who boarded a Swissair flight to Frankfurt, Germany.

An armed chase along the tarmac and other dramatic narrow escapes depicted in “Argo” never occurred during the real escape.

“It makes a great movie,” Mr. Taylor said.

Later the same day, Mr. Taylor closed the embassy and flew out of Tehran with his wife and the few remaining Canadian diplomatic staff members. When word filtered out that the Americans had been sneaked out with the help of the Canadians, the Iranian foreign minister seethed, “Sooner or later, somewhere in the world, Canada will pay.”

Kenneth Douglas Taylor was born Oct. 4, 1934, in Calgary. His father ran a printing shop.

After graduating from the University of Toronto, Mr. Taylor received a master’s degree in business administration from the University of California at Berkeley in 1959. At Berkeley, he met his Australian-born wife, Patricia Lee, who received a doctorate in epidemiology and became an AIDS researcher.

Mr. Taylor entered the Canadian foreign service in 1959 and had postings in Karachi, Pakistan, and London before going to Tehran. After serving as consul general in New York, he retired from the diplomatic service in 1984.

He stayed in New York as a senior vice president of Nabisco and later founded a public affairs consulting company.

Survivors include his wife and their son, Douglas Taylor, both of New York; and two grandchildren.

In a 2010 book, “Our Man in Tehran,” Canadian historian Robert Wright revealed that while Mr. Taylor was in Iran, he helped relay intelligence information through the Canadian Embassy to the CIA. He acted, in Wright’s words, as “the de facto CIA station chief.”

“Operating an espionage center with the Canadian embassy,” Mr. Taylor told NPR in 2012, “placed the embassy in certain degrees of jeopardy.”

But he added that he and his staff members “were quite prepared to take that risk, as I’m sure my colleagues at the American embassy would’ve done.”

Mr. Taylor, who lived in the United States the last 34 years of his life, was frequently approached by Americans who wanted to shake his hand offer their thanks.

“I enjoy that, of course,” he said, “because it is a sense of saying to Canada: This is what you did.”