MOSCOW — For several years a group of hackers have been posting letters and documents stolen from senior Russian officials with impunity. And then the nation’s spy agency tracked them down and offered them a deal.

A member of the Shaltai Boltai (Humpty Dumpty) group said in an interview broadcast Thursday that the hackers accepted the offer from the Federal Security Service, or FSB, the top KGB successor agency: show their spoils before publishing in exchange for protection.

But somehow the things went wrong for the group, and its leader and two other men have ended up behind bars.

Get Breaking News Delivered to Your Inbox

Alexander Glazastikov, who spoke to the independent Dozhd TV from Tallinn, Estonia, where he’s seeking political asylum, said his group had no connection to the hacking of Democratic Party emails during the 2016 U.S. election campaign. Former President Barack Obama’s administration had accused Russia of launching the hacking campaign to help Republican Donald Trump win, accusations that the Kremlin has denied.

“Our group has never attacked targets outside Russia,” Glazastikov told Dozhd. “We weren’t interested in the Democrats or the Republicans.”

He didn’t say if the FSB officers who approached the group were those who were arrested in December on charges of spying for the United States. The arrests reported by Russian media outlets fueled speculation that the officers could have been connected to hacking the Democrats.

While the interview provided no new information about Russian meddling in the U.S. elections, it offered a rare glimpse into the shadowy world of Russian politics, where hackers serve as a weapon for competing Kremlin clans and rival spy agencies.

Glazastikov said the hacking group’s leader, Vladimir Anikeyev, had offered to set up Shaltai Boltai as a resource that would release information serving public interests. Glazastikov said he joined the group because he was bored with his marketing job.

The group quickly won the limelight by publishing letters written by government officials, Kremlin-connected tycoons and artists that cast them as unscrupulous and cynical. And then Shaltai Boltai began to cash in on its fame by blackmailing its victims to make them pay to prevent the publication of their personal data.

Glazastikov said he believed the group crossed a red line for Russian officials in 2015, when it posted letters and documents from the chief of the Defense Ministry’s construction department and then followed up with an open letter to the head of military counterintelligence mocking the agency’s inability to keep secrets.

“We were playing with fire,” Glazastikov said. “The counterintelligence got very interested in us after that letter.”

He said unidentified people, possibly from the Defense Ministry, bought the cache of documents stolen from the military construction department chief for about $100,000.

Separately, the FSB, competing for influence with other spy agencies, got the hacking group in its crosshairs.

Glazastikov said Anikeyev, the hacking group’s leader, had told him the FSB contacted him via proxies to give a message: “Guys, we know all about you. We won’t arrest you, but we would like to know what you are doing.”

Neither the Defense Ministry nor the FSB has had any immediate comment about Glazastikov’s claims.

Glazastikov said Anikeyev didn’t name the FSB officers he was dealing with, and added that he doesn’t know if they were the officers of the FSB’s cybercrime division arrested on treason charges in December. Two of them have been named in Russian media as Col. Sergei Mikhailov, deputy head of the FSB’s Information Security Center (TsIB), and his subordinate, Maj. Dmitry Dokuchayev.

According to Russian media reports, Mikhailov was arrested in a way designed to sow fear in the ranks: He had a bag placed over his head while attending a meeting of senior FSB officials.

Glazastikov said Anikeyev had asked him to come to Russia, but he refused because he had a feeling that Anikeyev had been arrested and was making the request on officials’ orders. Another hacking group member, Konstantin Teplyakov, agreed to come and was arrested.

Anikeyev’s arrest was later officially announced.

Glazastikov said he didn’t know another alleged group member, Alexander Filinov, who also was arrested. Filinov showed up Thursday at a Moscow court, which extended his arrest until April.

Glazastikov said Anikeyev was maintaining links to hackers who stole personal data and also dealing with the victims and those who ordered the hackings. Glazastikov estimated the group earned up to $2 million since 2014, but a large share of the money was spent to cover “operational expenses.” He said he himself made less than $100,000.