The Russian woman arrested this week on charges of being a foreign agent has ties to Russian intelligence operatives and was in contact with them while in the United States, federal prosecutors said Wednesday.

Maria Butina, 29, also cultivated a “personal relationship” with an American Republican consultant as part of her cover and offered sex to at least one other person “in exchange for a position within a special interest organization,” according to a court filing.

After a hearing on Wednesday afternoon, U.S. Magistrate Judge Deborah A. Robinson denied Butina’s request to be released on bail, finding that no combination of conditions would ensure her return to court.

Prosecutors with the U.S. attorney’s office in Washington had argued strongly against her release, noting “her history of deceptive conduct.” They said Butina could slip into a Russian Embassy or a Russian diplomatic vehicle and get out of the country, and had connections with wealthy business executives linked to the Putin administration.

When she was arrested Sunday, she appeared to be planning to leave Washington and possibly the United States, they said: Her apartment was full of moving boxes, and she had transferred money to Russia in recent days.

The new allegations laid out Wednesday explicitly link Butina to Russia’s intelligence services for the first time, painting the portrait of a covert agent backed by powerful patrons who created a pretext for her presence in the United States. The details about her alleged activities injected even more drama into the case of the Russian gun rights activist, who in recent years cozied up to top U.S. conservatives, including the leadership of the National Rifle Association.

She once quizzed Donald Trump while he was a presidential candidate about his views on Russia and chatted briefly with the president’s son Donald Trump Jr. at an NRA meeting in May 2016.

In a court filing that could have been ripped from the television show “The Americans,” prosecutors described her manipulating a South Dakota political operative as part of her scheme and meeting for a private lunch in March with a Russian diplomat suspected of being a Russian intelligence officer — all while FBI agents watched.

Maria Butina was photographed by FBI agents having lunch in Washington with a suspected Russian intelligence operative in March. The photo was entered as evidence at a hearing Wednesday at which she was denied bond. (U.S. Attorney’s Office)

Butina, who came to the United States on a student visa in August 2016 to study at American University, was charged with conspiring to act as an agent of a foreign government and failing to register as an agent of a foreign government. Prosecutors say she worked to infiltrate American conservative groups to advance the Kremlin’s interests.

Through her attorney, Robert N. Driscoll, she pleaded not guilty at the hearing Wednesday. He has said she was not a Russian agent but instead a student interested in forming bonds with Americans.

In arguing that she should be released, Driscoll revealed that Butina had offered to assist law enforcement with a federal criminal investigation of an unidentified person in South Dakota.

A description of that person’s activities in court filings matches that of Paul Erickson, a South Dakota political operative with whom Butina was romantically involved, according to testimony she gave to Senate investigators earlier this year.

Erickson, who has not been charged, did not respond to requests for comment.

Assistant U.S. Attorney Erik M. Kenerson said the investigation in South Dakota was related to fraud, but he did not provide details.

Driscoll also argued that Butina had an opportunity to flee before her arrest, noting that FBI agents in tactical gear raided her apartment on April 25.

“Did she flee the country?” Driscoll asked. “Did she call the embassy? Did a Russian car roll up? She called her attorney, and we stood there and let the government go through her apartment for an entire day.”

A spokeswoman for the Russian Foreign Ministry on Wednesday called Butina’s arrest alarming, saying it was aimed at undermining the outcomes of this week’s meeting in Helsinki between President Trump and Russian President Vladi­mir Putin.

“You get the sense that someone grabbed a watch and a calculator to determine when the decision on Maria Butina’s arrest should be adopted to maximally undermine the outcomes of the summit that took place between the Russian and U.S. presidents. It was that deliberately timed,” Foreign Ministry spokeswoman Maria Zakharova said at a briefing in Moscow.

Prosecutors revealed Wednesday that after executing several search warrants, they learned Butina “was in contact with officials believed to be Russian intelligence operatives.”

A memo written by Kenerson states that Butina maintained contact information for employees of the Russian FSB, the successor agency to the Soviet Union’s KGB, and was “likely in contact with the FSB throughout her stay in the United States.”

Among the documents seized by the FBI from Erickson’s residence was a handwritten memo titled “Notes on Maria’s ‘Russian Patriots In Waiting’ Organization,” according to an exhibit submitted by prosecutors. The memo included the question, “How to respond to FSB offer of employment?”

A document seized from the home of a South Dakota consultant who was in a relationship with Maria Butina references a job offer from the FSB, Russia’s internal security organization, the successor to the KGB. The memo was partially redacted by prosecutors. (Aliona Manakova/Getty Images)

To buttress the government’s claim that Butina was a Russian government agent and a possible flight risk, Kenerson entered three photos into evidence. One of them was a surveillance photo of Butina and a Russian diplomat having dinner in a Washington restaurant in March. A menu board in the photo matches one featured in a photo of La Piquette, a French restaurant in Cleveland Park.

Kenerson said the man was “suspected of being a Russian intelligence operative” and the photo was taken shortly before he was ordered to leave the country as part of U.S. sanctions. Driscoll said the photo was simply two Russians having dinner together in America and proved nothing.

Prosecutors have said Butina’s main Russian contact was a high-level government official who matches the description of Alexander Torshin, a Russian central banker and former senator from Putin’s party.

In direct messages exchanged through Twitter, prosecutors said, she and Torshin agreed that she could operate only in secret.

“Only incognito!” she wrote in one message in October 2016. In a note in March 2017, Torshin wrote, “You have upstaged Anna Chapman,” a reference to a Russian spy who had lived freely in the United States for years before her 2010 arrest.

A selfie by Butina standing in front of the Capitol on Inauguration Day in 2017 was also entered by prosecutors into evidence Wednesday. Butina sent the photo to Torshin in Russia, who responded, “You’re a daredevil girl,” according to court filings.

“Good teachers!” Butina wrote back.

Driscoll said the photo was no different from those taken by any other Russian tourist.

A selfie taken by Maria Butina on the Mall on Jan. 20, 2017, at the inauguration of President Trump. She sent it to a Russian official who called her a “daredevil girl” for taking it. (U.S. Attorney’s Office)

The Washington Post reported earlier this year that Butina was spotted at a ball when Trump was sworn in to office in January 2017, part of a group of Russians whose presence at Trump’s celebration drew the attention of the FBI.

Kenerson also entered into evidence a photo of Butina standing with Sergey Kislyak, the former Russian ambassador to the United States who privately discussed U.S. sanctions on Russia with incoming national security adviser Michael Flynn in December 2016. Driscoll said the photo was taken at a Russian cultural event and had no significance.

In addition to her apparent ties to the Russian government, the new court filing alleges that Butina had ties to “wealthy businessmen in the Russian oligarchy.”

Prosecutors state that her Twitter messages, chat logs and emails referred to a Russian businessman “with deep ties to the Russian Presidential Administration,” that this unidentified person often travels to the United States and has been referred to as her “funder” in Butina’s correspondence. In 2014, Butina engaged in text messages with a different wealthy Russian businessman concerning budgets for her trip to America and meetings with her “funder,” Kenerson wrote.

Those officials were not identified.

Prosecutors say Butina got help in making contact with influential Americans from Erickson, a political consultant from South Dakota who once helped run Pat Buchanan’s presidential campaign and whom Butina met after hosting him and other American gun enthusiasts in Russia in 2013.

While the two lived together and had a personal relationship, prosecutors said it was a “duplicitous” one, saying that they found papers in which the 29-year-old “expressed disdain” about having to live with 56-year-old Erickson.

“On at least on occasion, Butina offered an individual other than [Erickson] sex in exchange for a position within a special interest organization,” according to Wednesday’s filing.

The organization was not identified. Driscoll said Butina denies offering anyone sex in exchange for access.

Prosecutors also said in court filings Wednesday that Butina had plotted with Erickson how she should manage visas to remain in the United States. They surveilled Butina and Erickson entering a Washington bank last week and sending a $3,500 wire transfer to Russia, and then on Saturday inquiring at a U-Haul facility about renting a truck and purchasing moving boxes.

And they alleged that Erickson would help Butina complete her academic assignments for American University “by editing papers and answering exam questions.”

In an email in 2017, Butina told The Post that Erickson was “one of my friends and political mentors.” She said he had helped her form a consulting company in South Dakota called Bridges LLC, which she had intended to use to pay for her studies. But she said that she ultimately found “financial aid” and that the company was inactive.

An American University spokesman, who has confirmed Butina received a master’s degree this year, declined to comment but pointed to a university policy that allows the school to revoke the degrees if an internal investigation finds a former student engaged in academic misconduct.