The federal judge overseeing the criminal trial of longtime Trump confidant Roger Stone imposed a gag order Friday, ordering Stone to limit his public comments near the federal courthouse in Washington but putting greater constraints on attorneys and potential witnesses, who were told not to make statements that might prejudice jurors.

U.S. District Judge Amy Berman Jackson in Washington warned Stone that based on his conduct, she could later tighten the order, which she issued invoking a court rule to rein in pretrial publicity in sensational cases.

Stone, 66, a longtime GOP operative and self-described “dirty trickster,” has pleaded not guilty to charges of lying about his efforts to gather information about hacked 2016 Democratic Party emails that were published by the WikiLeaks organization.

In a four-page order, Jackson said she had weighed Stone’s assertion of his constitutional rights to free speech as a writer and political commentator. Jackson’s order barred prejudicial statements “to the media or in public settings” by any attorneys or potential witnesses in the case to safeguard the defendant’s right to a fair trial, maintain the dignity of the court and the safety and security of court personnel and the public. Her order also noted concern that a small crowd of chanting and sign-bearing demonstrators for and against Stone lined a courthouse entrance after his arraignment.

Jackson further directed Stone and other participants not to make any statements intended to influence the case or “interfere with the administration of justice” in the “immediate vicinity” of the courthouse.

Stone on Friday said in a text message, “I am pleased that the judge’s order leaves my first amendment right to defend myself in public intact.” He added, “I will of course continue to be judicious about my comments regarding the case.”

The court said Stone’s case would remain assigned to Jackson, over his defense lawyer’s objections, who sought to have the case randomly assigned to another judge in the courthouse.

However, Stone has used the threat of such an order to raise money for his legal defense fund and to go on a public offensive against the court, prosecutors with Mueller’s office and the U.S. attorney’s office of the District.

In a videotaped fundraising appeal for his legal defense fund that he posted to his Instagram account hours earlier, Stone referred to Jackson, a 2011 court appointee, saying, “Now a federal judge appointed by Barack Obama threatens to gag me so I can’t defend myself in public and raise the money necessary for a vigorous legal defense.”

In the video Stone wears a blue T-shirt emblazoned with the words, “Roger Stone did nothing wrong!”

The special counsel’s office made a pitch in an earlier court filing that the Stone case should be considered “related” to a case filed in July against 12 Russian military intelligence officers accused of hacking the Democratic Party during the 2016 campaign and distributing stolen documents through WikiLeaks. Jackson has that case.

Prosecutors argued Stone’s alleged lies to Congress grew out of an investigation into the hacking. And they said “several” search warrants served in the hacking investigation were executed on online accounts that contained Stone’s communications, particularly with WikiLeaks and Guccifer 2.0, a person who distributed the stolen material online. Prosecutors previously alleged Guccifer 2.0 was an account operated by Russian military intelligence .

Stone has made public direct messages he exchanged with Guccifer 2.0 through twitter and also with a WikiLeaks account. He has said the communications are innocuous and do not indicate any advance knowledge of plans to release stolen emails.

Stone’s lawyers contended the two cases were unrelated.

A seven-count indictment unsealed Jan. 25 alleges that Stone sought information about the emails before the election at the direction of an unidentified senior Trump campaign official. He faces charges of lying, obstruction and witness tampering, including by pressuring another witness to lie or refuse to talk to Congress.

Stone, a veteran GOP operative and a friend of Trump’s for four decades, briefly advised the presidential campaign in 2015 and remained in contact with Trump and top advisers through the election.

Prosecutors allege that in 2016, Stone repeatedly sought to learn when potentially damaging internal emails from Hillary Clinton’s campaign would be released, but after the election tried to cover up what he had done by lying about it in his testimony to Congress.

In Stone’s indictment, prosecutors allege that after the initial release of stolen Democratic emails on July 22, 2016, “a senior Trump campaign official was directed to contact Stone about any additional releases and what other damaging information Organization 1” had regarding the Clinton campaign.

The indictment does not name the campaign official or say who directed the alleged outreach to Stone. People familiar with the case identified “Organization 1” as WikiLeaks, the global anti-secrecy group founded by Julian Assange.

Stone has repeatedly denied having any contact with Russia or WikiLeaks. Stone, WikiLeaks and Assange have said they never communicated with one another.

Stone is free on bond and limited to travel between South Florida, Washington and New York City.

Rosalind S. Helderman contributed to this report.