WASHINGTON — A federal judge imposed a gag order Monday on the lawyers involved in the case of a Russian gun rights activist accused of working in America as a secret agent for Moscow.

U.S. District Judge Tanya Chutkan also denied a defense request that the defendant, Mariia Butina, be released on bail and placed under house arrest.

The gag order comes days after prosecutors admitted they were wrong to accuse Butina of trading sex for access, saying they misinterpreted one of Butina's text message exchanges. But the prosecutors said there is other evidence to support keeping Butina in custody.

Chutkan said she was "dismayed" by the mistake and by the "rather salacious allegations" made by prosecutors. She said the joking nature of the text message exchange was immediately "apparent on their face" when she read them.

Prosecutors charge that Butina, 29, gathered intelligence on American officials and political organizations and worked to develop relationships with American politicians via her contacts with the National Rifle Association. They say her work was directed by a former Russian lawmaker who was sanctioned this year by the U.S. Treasury Department for his alleged ties to Russian President Vladimir Putin.

Butina has pleaded not guilty to the charges of conspiracy and acting as an unregistered foreign agent for Russia. Her attorney Robert Driscoll has denied that Butina is a Russian agent, calling the case "overblown." He has said his client was merely a student who wanted to see a better relationship between the U.S. and Russia and sought to network with influential people in American politics.

In imposing the gag order, Chutkan determined that Driscoll had "crossed the line" in his frequent public comments about the case.

"Your work defending your client needs to happen in this courtroom, not on the public airwaves," she said.

Chutkan said the combination of the headline-grabbing erroneous sex allegations and Driscoll's frequent public criticisms will make it harder to organize an impartial jury in the District of Columbia, which has just over 700,000 residents.

"Our jury pool is relatively small," she said. "It really makes it very difficult to have a fair trial."

Despite the embarrassing government walk-back, Chutkan agreed with the prosecution's contention that Butina should be kept in custody. Prosecutors had raised the prospect of her being swept out of the country by Russians using their diplomatic immunity to shield her from U.S. law enforcement. The U.S. does not have an extradition treaty with Russia.

"The court finds that there are no conditions or combination of conditions that would ensure Ms. Butina's availability to this court," Chutkan said.

Driscoll responded that Butina could have fled the country multiple times as the investigation into her activities was ongoing. But Chutkan responded the flight risk possibility is even more serious now that Butina has been formally charged.

"She has now been indicted," Chutkan said. "She faces very serious criminal penalties."