Peter Earnest, a veteran of the CIA’s Cold War clandestine operations who ran agents in Eastern Europe and the Middle East, then helped promote and preserve the history of espionage while serving as the founding executive director of the International Spy Museum in Washington, died Feb. 13 at a hospital in Arlington, Va.

Through his speeches, books, interviews with journalists and leadership of the Spy Museum, Mr. Earnest helped demystify the world’s second-oldest profession, introducing people to the techniques, influence, triumphs and shortcomings of intelligence gathering around the globe.

“Unlike what you would typically expect from someone in the intelligence/spy community, in many ways he was more of an extrovert than an introvert,” said Mark S. Zaid, a national security lawyer who got to know Mr. Earnest.

“When he was doing the programming he came across as very warm, knowledgeable and inviting — all the things you wouldn’t want for a spy agency, but you would want for a museum about spying.”

Mr. Earnest acknowledged that his personality sometimes made it difficult to spend years working undercover. “It’s hard when you’re an open person by nature,” he told The Washingtonian magazine in 2013. “In some cases, people say, ‘You don’t seem like a spy.’

“The best spies don’t seem like spies.”

Mr. Earnest worked at the Central Intelligence Agency for 36 years, serving for more than two decades as a case officer in the clandestine service. He ran and recruited agents, conducted covert operations and in the late 1970s helped safeguard Arkady N. Shevchenko, a top United Nations official who became the highest-ranking Soviet diplomat to defect to the United States.

Mr. Earnest later came out of the shadows to serve as the agency’s media relations director and spokesman, trying to strike a delicate balance between transparency and the protection of government secrets. A few years after his retirement in 1994, he was recruited to join the International Spy Museum, which officially opened in downtown Washington in 2002.

“The message here is that spies change history,” he told the Chicago Tribune that year. “We don’t see ourselves as representing the American intelligence community or defending it as such,” he added. “The intent here is not to glorify espionage or celebrate spies but to depict them. We’re simply saying, ‘Here they are. This is what we did.’ ”

Founded by media magnate Milton Maltz, who helped bring the Rock & Roll Hall of Fame to Cleveland, the museum showcases thousands of years of espionage history, offering information on the ancient Chinese general Sun Tzu, U-2 spy plane pilot Francis Gary Powers and the workings of the Nazi Enigma code machine, as well as the gadgets of fictional spies like James Bond and Austin Powers.

“We’re not trying to teach people how to spy,” Mr. Earnest said. “We’re saying this is the true nature of a discipline which is trying to get information that is being denied or not available. How do you go about finding things out?”

During his tenure as executive director, the museum hosted more than 9 million visitors, launched a podcast, transitioned to a nonprofit institution and broke ground on its new home in DC’s L’Enfant Plaza. The building opened in 2019, a year after Mr. Earnest retired from the job, shifting to a role on the museum’s board of directors.

“He had a huge role in which stories we would tell and how we would tell them,” museum president Tamara Christian said, crediting Mr. Earnest with shaping immersive exhibitions such as “Operation Spy,” in which visitors assumed the role of covert operatives.

Edwin Peter Earnest was born in Edinburgh, Scotland, on New Year’s Day, 1934. His father was a U.S. Foreign Service officer who when Mr. Earnest was 12. His mother, who was English, became a naturalized U.S. citizen and joined the State Department, rising to become a consular affairs officer.

Mr. Earnest grew up in Bethesda, Md., graduating from Georgetown Preparatory School. He studied history and government at Georgetown University, received a bachelor’s degree in 1955 and served in the Marine Corps, doing a tour in Japan.

His then-fiancee, Janet Chesney, worked at a CIA field office in Washington and told colleagues that Mr. Earnest was getting out of the service, leading an agency official to approach him about joining the CIA. He signed up in 1957 and was soon dispatched overseas.

“My wife and I were young and naive — we took what came. If we’d known certain things before we went, maybe we wouldn’t have gone,” he told The Washingtonian. “There was a great sense of serving the country. That has a certain redeeming quality, thinking, ‘This is hard, and these are the risks. There is a purpose to this.’ If you’re disappointed in that regard, then it could easily lead to depression.”

In a video interview for the Spy Museum, Mr. Earnest described what he called “my Bond moment” at the CIA, in which he slipped out of a black-tie reception at the home of an asset and bugged the person’s office. Lying on his back, with a handkerchief positioned on his chest to catch the shavings, he drilled small holes in the bottom of the target’s desk and installed a recording device.

“No one had noticed that I was missing. No one asked where I had been,” he recalled. The bug revealed that the asset was working as a double agent, leading Mr. Earnest to “terminate” their relationship, as he put it.

Mr. Earnest was working at agency headquarters in Langley, Va., when he became closely involved with Shevchenko, a Soviet diplomat and U.N. undersecretary general who had been secretly working for the CIA before he defected in 1978.

Whisked away to safe houses in New York and in the Washington area, Shevchenko was debriefed and protected by a joint CIA-FBI team that was supervised by Mr. Earnest, according to his friend David G. Major, a retired FBI agent who worked on the operation.

Major recalled that he playfully nicknamed Mr. Earnest “God” after watching in surprise as the CIA officer whipped out $3,000 in hundred-dollar bills while arranging for Shevchenko to take a vacation to the Caribbean. “I said, ‘Only God can do that.’ Because the FBI couldn’t: We had to do all kinds of paperwork, get approvals” to obtain large amounts of cash.

One of Mr. Earnest’s subordinates in the case was Aldrich Ames, who later sold American secrets to the KGB and was sentenced to life in prison for espionage….

Mr. Earnest also served in the CIA inspector general’s office and worked as the agency’s chief liaison with the U.S. Senate. He received honors including the Intelligence Medal of Merit and Career Intelligence Medal, and became president and chairman of the Association of Former Intelligence Officers.

After retiring from the agency, he co-wrote books including “Business Confidential” (2010), a management guide that included examples from CIA operations, and “Harry Potter and the Art of Spying” (2014), which explored the spy craft employed in J.K. Rowling’s wizarding novels….

Mr. Earnest’s marriage to Chesney ended in divorce, and in 1988 he married Rice, a fellow CIA veteran….

During his years at the Spy Museum, Mr. Earnest sometimes met with school groups visiting the institution, chatting with them about his career at the CIA. Their first question was always the same, his wife said: “How many people did you kill?”

The answer was “none,” Mr. Earnest told Stephen Colbert in a 2008 interview. When the TV host pressed him — “Would you tell me if you had?” — Mr. Earnest replied, “I would probably hedge on that.”

“I’ll put you down for seven,” Colbert said.

Harrison Smith is a reporter on The Washington Post’s obituaries desk. Since joining the obituaries section in 2015, he has profiled big-game hunters, fallen dictators and Olympic champions. He sometimes covers the living as well, and previously co-founded the South Side Weekly, a community newspaper in Chicago.