WASHINGTON (Reuters) - A visibly angry judge on Thursday ordered President Donald Trump’s former political adviser Roger Stone to stop speaking publicly about U.S. Special Counsel Robert Mueller’s criminal case against him or else he will be sent to jail pending trial.

In a tense court hearing on Thursday, U.S. Judge Amy Berman Jackson of the U.S. District Court for the District of Columbia said that Stone’s apology and explanations for why he posted a photo of her next to the image of the crosshairs of a gun on his Instagram account were not credible.

Jackson made her ruling after a highly unusual hearing in which Stone, who is charged with crimes related to Mueller’s investigation of Russian interference in the 2016 U.S. election, took the stand to testify about the posting.

Stone’s seemingly contradictory statements and at times foggy recollections about the post’s origins during a cross-examination by the government frustrated Jackson, who later concluded he “could not even keep his story straight on the stand.”

Stone, a longtime Republican political operative, friend of Trump and self-proclaimed “dirty trickster,” was arrested on Jan. 25. He has pleaded not guilty to charges of making false statements to Congress, obstruction and witness tampering.

Besides probing the conclusions of U.S. intelligence agencies that Moscow ran an operation to hack Democratic Party computers and spread disinformation to undermine candidate Hillary Clinton and the American electoral process, Mueller is also investigating possible coordination between the Trump campaign and Moscow officials.

Trump denies collusion and Russia denies allegations of meddling.

Stone apologized to the judge for the post on Instagram and asked for a second chance.

“Thank you, but the apology rings quite hollow,” Jackson told Stone.

“What all of this means, Mr. Stone, is that any violation of this order will be a basis for revoking your bond and detaining you pending trial. So I want to be clear - today I gave you a second chance. But this is not baseball. There will not be a third chance.”

Jackson had ordered Stone to appear in court to review whether the posting on his Instagram account violated his conditions of release and a narrowly tailored media gag order she imposed last week. He is out on a $250,000 bond and is free to travel without court permission to certain cities.

The media gag order did not explicitly bar Stone from speaking publicly about the case as long as he was not on courthouse grounds.

However, it cautioned him to tread carefully and said he would not be able to complain later if he decided his own comments had tainted the jury pool.

Slideshow ( 4 images )

The original posting on Monday on Stone’s Instagram account not only contained a photo of Jackson next to the crosshairs, but also had text that ranted against Mueller as a “hitman” and called Jackson “an Obama-appointed judge” a reference to Trump’s Democratic predecessor in the White House.

Stone later took the image down and apologized, but afterwards he gave an interview on conspiracy website Infowars defending the post.

At Thursday’s hearing, Stone said: “I abused the order,” Stone said. “I am kicking myself over my own stupidity.”

Slideshow ( 4 images )

“Your honor, I can only beseech you to give me a second chance,” Stone said. “Forgive me the trespass. I’m hurtfully sorry.”

The investigation has clouded Trump’s two years in office and has been a frequent target of the president and his allies. So far, the investigation has ensnared 34 people.

The most tense exchanges of Thursday’s hearing were during a cross-examination by prosecutor Jonathan Kravis, who repeatedly tried to get Stone to reveal who had selected the image for him.

Stone testified he has between five and six volunteers who come and go freely from his home and have access to his cell phone. He rattled off the names of some volunteers, but also said he could not remember all of them.

At first when asked by his lawyer Bruce Rogow if one of those volunteers had posted the image, Stone testified he did not select or review it.

Later, however, Stone said he had seen the picture and posted it himself, but did not realize its implications.

“Excuse me, did you not just tell me under oath less than five minutes ago that someone else posted it?” Jackson asked Stone.

“That’s not inconsistent - I didn’t choose the image. I did post it,” Stone replied.

Later, he again changed the story, saying he had at his disposal several images of the judge to choose from before the posting.

“I erased all of the images of your honor because I did not want to make the same mistake twice,” he said.

“You had a choice?” an incredulous Jackson asked. “You closed your eyes and picked?”