She was once called the “Queen of Cuba.” The Washington Post called her the “most important spy you never heard of.” She was arrested in 2001 after orchestrating a 17-year campaign of subterfuge that filtered untold secrets to the Cuban regime and is serving a 25 year prison sentence.

But the events that precipitated the capture of Ana Montes have long remained murky — until President Obama’s normalization of diplomatic relations with Cuba on Wednesday brought further clarity.

As a precondition to their historic agreement this week, the United States and Cuba swapped captured spies. And the spy Cuba released was a very important one. According to American officials, he provided critical information that led to the arrests of the “Cuba Five” and several highly placed spies, as the Post’s Adam Goldman reported. One of them, it turned out, was Montes.

During a news conference on Wednesday, President Obama announced that two Americans who had been held captive in Cuba had been returned to the U.S., including USAID contractor Alan Gross. (AP)

That information revives one of the oddest tales to emerge from decades of espionage. At its center is Montes, an enigmatic, fiercely intelligent one-time Defense Intelligence Agency official who betrayed her country. Rarely convivial, she fit the “stereotypical mold for a spy,” investigators later said. As the Defense Intelligence Agency’s top Cuba analyst, she slid undetected into meetings with the Joint Chiefs of Staff, National Security Council and even the president of Nicaragua.

But Montes was a mystery. Espionage didn’t make her millions of dollars like other famous American spies. It wasn’t frustration at work that drove her. Nor infidelity. Nor pathology. The intelligence official had been a “quiet, frugal, and unassuming neighbor,” as one declassified Department of Defense report put it.

So how did a woman who grew up in Iowa and Kansas become a traitor? How did someone who cared nothing for money or professional achievement find herself donning a wig for rendezvous with Cuban handlers? And what made her stick with it for so long? By the end, she was idiosyncratic: She wore gloves when she drove, she only ate unseasoned boiled potatoes, she shunned social contact.

To find answers, you must travel back to her turbulent childhood under the yoke of a father she said “happened to believe that he had the right to beat his kids,” according to the Defense Department. That abuse generated Montes’s desire to retaliate against authority — and made her a potential recruit for Cubans seeking to infiltrate Washington.

Which was exactly what happened in a classroom at Johns Hopkins University, where Montes pursued a master’s degree in the 1980s. There, she inveighed against U.S. policies in Latin America and especially Nicaragua. To her, President Ronald Reagan was the devil.

So one day in the summer of 1984, a fellow student approached her. He asked her to meet some friends who wanted help translating Spanish articles into English. The friend turned out to be a Cuban intelligence official. It didn’t take much convincing to get Montes to come aboard.

“In her view, Cuba was victimized by U.S. repression and concluded that she had the ‘moral right’ to provide information to Cuba,” Defense Department investigators wrote in 2005. “Throughout her career as a clandestine agent, she believed that ‘destiny was offering me an opportunity to do everything that I could do to help Cuba.’ She often exclaimed, ‘I couldn’t give up on the people I was helping.’ In sum, she indicated that she ‘felt morally rewarded.'”

Thus began a career in espionage that surely soared higher than her handlers’ highest hopes. Montes was soon rising through the ranks of the Defense Intelligence Agency, the Miami Herald reported. Playing both sides, she took risks. She met Cuban handlers at D.C. Chinese restaurants. She used a fake Cuban passport.

But she wasn’t sloppy. She never brought paper home. She didn’t spend lavishly — or much at all. She memorized document after document, returning home every night to regurgitate classified files onto her Toshiba laptop. She took her orders from Cuba through a shortwave radio that spewed out 150 numbers she decoded into Spanish-language text.

So how did this spy — who didn’t make enemies or mistakes and didn’t leave a paper trail — finally get caught?

“We only really catch the dumb spies,” one counterintelligence official said. “And the only reason we caught her is because we got lucky.”

Luck, in fact, had little to do with it. Montes, a double agent working for Cuba in Washington, was caught by a double agent working for Washington in Cuba.

More than 1,200 miles south, an unidentified Cuban-born American spy — the same one released as a result of Obama’s action this week — was apparently monitoring Montes. He eventually told American officials of Montes’s background.

Still, the precise events that precipitated her arrest in 2001 remain murky, even after Wednesday’s revelations.

The Post reported that a Defense Intelligence employee named Scott Carmichael was approached in September 2000 by a “female intelligence officer,” who informed him of an unidentified government employee who used a Toshiba computer secreting information to the Cubans. Carmichael eventually sniffed out Montes, the report said. She was arrested in 2001 weeks after the Sept. 11 attacks, and sentenced to 25 years in prison in 2002.

But who was the Cuban agent who, working secretly for the U.S., turned Montes in? We still don’t know.

“From the language of the Pentagon report, it was probably not a defector, but more likely a renegade or compromised Cuban intelligence officer,” the Miami Herald suggested earlier this year. “If so, Montes was done in by one of her own so-called ‘comrades.'”

Montes’s capture hasn’t softened her zealotry. Even after years of incarceration at a Texas prison, she said she doesn’t regret her betrayal.

“Prison is one of the last places I would have ever chosen to be in, but some things in life are worth fighting for,” she once wrote a friend, Jim Popkin reported in a Washington Post Magazine article. “Or worth doing and then killing yourself.”