Martin Shkreli is heading to jail.

A federal judge Wednesday revoked the former pharmaceutical exec's bail after he offered $5,000 to anyone who could grab a strand of Hillary Clinton's hair.

Judge Kiyo Matsumoto said Shkreli, who was convicted of fraud in August and is awaiting sentencing, has "demonstrated that he has posed a real danger."

In a Facebook post last week, Shkreli promoted a conspiracy about the Clinton Foundation and said he would pay any person who could procure a lock of hair from the former presidential candidate.

Prosecutors said the post reflected "an escalating pattern of threats and harassment," adding that it had triggered an investigation by the Secret Service that required "a significant expenditure of resources."

In a hearing in Brooklyn federal court, Judge Matsumoto said she was particularly concerned that he had "doubled down" on his challenge for someone to grab Clinton's hair. Shkreli said he required a hair with a follicle while urging his social media followers not to hurt anyone.

She said his behavior indicates he is "an ongoing risk to the community."

Until Wednesday, Shkreli remained free on $5 million bail. His sentencing is set for January 16.

Shkreli, 34, has called the post "satire."

He ultimately asked Judge Matsumoto not to penalize him for "poor judgment" in a letter filed Tuesday.

"I understand now, that some may have read my comments about Mrs. Clinton as threatening, when that was never my intention when making those comments," Shkreli wrote in the letter. "I used poor judgment but never intended to cause alarm or promote any act of violence whatsoever."

Related: Shkreli apologizes for Hillary Clinton post

His defense lawyer, Benjamin Brafman, initially argued that Shkreli has a nonviolent background and was convicted on a nonviolent crime. He conceded that the comment was "stupid."

"Stupid doesn't make you violent. Sometimes stupid is just plain stupid," he said.

Once his client was remanded, Brafman pleaded with the judge to ban his client from social media instead of sending him to jail.

Shkreli was convicted in August of two counts of fraud and one count of conspiracy for misleading investors in his hedge funds.

The most serious count carries a maximum prison term of 20 years.

Shkreli first gained notoriety in 2015 when he raised the price of a pill used by AIDS patients from $13.50 to $750 while he was CEO of Turing Pharmaceuticals. His bombastic personality and prolific use of social media has kept him in the spotlight since then.

Even after his conviction, he continued livestreaming on YouTube from his apartment, predicting that his sentence would be "close to nil."

Shkreli's online harassment of a Teen Vogue editor in January, which got him kicked off Twitter, also came up during Wednesday's hearing. He made sexually explicit comments about the editor on Facebook the night before closing arguments in his criminal trial.

-- CNNMoney's Aaron Smith contributed to this report.