The FBI was closing in on a Defense Intelligence Agency employee who was allegedly a Cuban spy in late 2000. Soon, undercover agents would start driving and walking behind Ana Montes, the top military and political analyst for the organization on Cuba. Despite the fact that she had a cellphone in her purse, they caught her making calls on a pay phone. They seized Montes’ mail and looked through the garbage outside of her Washington apartment.

According to current and former U.S. intelligence officials, Montes had been spying for Cuba for nearly 17 years and had shared so much sensitive information about DIA employees and covertly installed listening devices that she essentially undermined every method the United States used to monitor the Castro regime. That makes Montes one of the most damaging spies of her time, they said.

It was laborious and risky to launch an investigation into a decorated intelligence officer whom coworkers referred to as the “Queen of Cuba.” The FBI nearly shot itself in the foot almost as soon as it started.

The error was unintentional. The Office of Foreign Missions of the State Department was typically informed whenever the bureau started an intelligence investigation that could upset foreign governments or American foreign policy (OFM). It was a dozy organization in charge of monitoring foreign diplomats’ travel and supervising initiatives like plans to establish new embassies or consulates in the country. Not exactly the scene for a spy thriller.

Terry Holstad, who was in charge of the FBI’s Cuba unit at the time, didn’t hesitate to inform Robert Hanssen, a seasoned agent and longtime colleague who served as the bureau’s liaison to the OFM, about the covert Montes investigation.

Holstad and the rest of the FBI were unaware of Hanssen’s more than 20-year history of spying for Russia. He provided the KGB with thousands of pages of classified documents that contained information about American nuclear war planning and weaponry. According to a review by the inspector general of the Justice Department, Hanssen was “the most damaging spy in FBI history” and compromised the identities of numerous human sources, at least three of whom were put to death.

Holstad recalled telling Hanssen about the Montes case just a few months prior to his arrest in February 2001.

Jim Popkin, an investigative journalist, discovered and described the precarious turn in the Montes case in a recent book. He wrote a lot about Montes, whom he referred to in a 2013 feature for The Washington Post as “the most significant spy you’ve never heard of.”

As a member of a team assembled by the CIA to evaluate the harm Hanssen’s espionage had caused, Holstad claimed he spent hours interviewing Hanssen in a Virginia jail and later in a supermax prison in Colorado. Despite admitting to spying for Russia, Hanssen claimed that he was only interested in sharing information about Russia and denied informing his handlers of the FBI’s investigation into a Cuban spy, according to Holstad.

The terrorist attacks of September 11, 2001, in part, brought an end to Montes’s career as a spy. The DIA was getting ready to put Montes on a team that would have knowledge of potential targets for American bombing in Afghanistan. It was already possible for the FBI to make an arrest for her. When he was the director of the DIA at the time, retired Vice Adm. Thomas Wilson reportedly called the bureau and demanded that they remove Montes from the streets.

On September 21, 2001, Montes was taken into custody at the DIA’s main office and led out in handcuffs. Senior members of the Cuban government publicly praised Montes and honored her work, portraying her as a comrade in arms in the struggle for socialism and against the Reagan administration’s support for anti-communist rebels in Nicaragua.

Montes wrote to a friend after Popkin’s article appeared in The Post, and the friend gave the letter to the writer. Montes “mocked” the story, Popkin writes in his book, and said, “she would much have preferred a clinical analysis of why she spied, with a history lesson for readers on the U.S. attempts to ‘unjustly overthrow the government of Nicaragua in the 1980s,’ and other examples of what American administrations have done to foreign countries from the nineteenth century to today. In Ana’s recounting, gone would be any personal accountability, replaced by fact-laden stories of American hostility and imperialism worldwide.”