This story has been updated with details of Martin Shkreli’s incarceration.

NEW YORK — A federal judge on Wednesday revoked the $5 million bail of Martin Shkreli, the infamous former hedge fund manager convicted of defrauding investors, after prosecutors complained that his out-of-court antics posed a danger to the community.

While awaiting sentencing, Shkreli has harassed women online, prosecutors argued, and even offered his Facebook followers $5,000 to grab a strand of Hillary Clinton’s hair during her book tour. Shkreli, who faces up to 20 years in prison for securities fraud, apologized in writing, saying that he did not expect anyone to take his online comments seriously, and his attorneys pleaded with the judge Wednesday to give him another chance.

“The fact that he continues to remain unaware of the inappropriateness of his actions or words demonstrates to me that he may be creating ongoing risk to the community,” said U.S. District Judge Kiyo Matsumoto, in revoking his bond.

“This is a solicitation of assault. That is not protected by the First Amendment.”

[Martin Shkreli wanted to be an Internet supervillain. This time it cost him.]

Shkreli, wearing a lavender button-down shirt and slacks, was taken into custody immediately after the hour-long hearing. He did not appear to react at the judge’s decision though he appeared more nervous than when he entered court and refused to ride the elevator with one reporter because they were “fake news.”

By early Thursday morning, Shkreli had been assigned an inmate number at the Metropolitan Detention Center in Brooklyn.

Shkreli, 34, is best known for raising the price of an AIDS drug by 5,000 percent but he was convicted by a Brooklyn jury of defrauding the investors in his hedge funds. Shkreli lied to obtain investors’ money then didn’t tell them when he made a bad stock bet that led to massive losses, prosecutors argued. Instead, they said, he raised more money to pay off other investors or took money and stock from a pharmaceutical company, Retrophin, he was running.

Shkreli, who has indicated that he will appeal his conviction, argued at trial that he ultimately made money for his investors and did not intend to defraud them.

Instead of shrinking from the public outrage that has followed him for two years, Shkreli has mounted an erratic and sometimes outrageous online defense of himself, appearing to revel in the negative attention.

His 70,000 Facebook followers do not take his statements seriously, said Shkreli’s attorney Benjamin Brafman. “He did not intended to cause harm,” he said. “Being inappropriate does not make you a danger to the community.”

“He says things that are stupid. I don’t think stupid makes you violent,” Brafman said.

Shkreli’s lawyers compared his online comments to the political humor of Kathy Griffin, who once held up a photograph of a faux bloody head of President Trump. They also compared him to Trump himself. During the campaign, Trump used “political hyperbole,” Shkreli’s attorneys said, when he said that Clinton, his Democratic opponent, would abolish the Second Amendment if elected. “By the way, and if she gets to pick her judges, nothing you can do, folks. Although the Second Amendment people, maybe there is, I don’t know,” Trump said.

“He did not hold up the severed head of the president of the United States like Kathy Griffin,” Brafman said.

But prosecutors argued that Shkreli already had been given plenty of opportunities to act appropriately. His posts about Hillary Clinton and female journalists show an “escalating pattern of violence against women that is incredibly disturbing,” Jacquelyn Kasulis, the lead prosecutor said. “It is clear that he is reckless. He knew exactly what he was doing. He has to go in. … He doesn’t respect the rule of law.”

They noted his post was taken seriously enough that the Secret Service sought an interview with Shkreli and had to increase the security measures around Clinton.

After a person is convicted, it is up to them to prove that they should be out on bail pending sentencing, prosecutors argued. “He is not special by any stretch of the imagination. He should be incarcerated because he is a felon,” Kasulis said.

Matsumoto appeared particularly concerned that one of Shkreli’s Facebook followers could take his offer of $5,000 for a strand of Clinton’s hair seriously. Shkreli said he wanted the hair — with a follicle — to compare Clinton’s DNA to a sample he already had. His attorneys said the post was satire and could not be taken seriously.

“What is funny about that,” a visibly frustrated Matsumoto said. “He doesn’t know who his followers are. He doesn’t know if someone it going to take his offer seriously. … He is soliciting an assault on another person for $5,000.”

This is not the first time prosecutors have complained to Matsumoto about Shkreli’s conduct. During the trial, Matsumoto chastised Shkreli for speaking with reporters in the courthouse where jurors could potentially hear him. Prosecutors had complained Shkreli’s comments — including mocking them as the “junior varsity” — were inappropriate and could taint the jury pool. Shkreli apologized after that incident too.

“Shkreli has again proven he’s his own worst enemy [and]… doesn’t have the impulse control needed to keep him out of jail,” said James Goodnow, an attorney with Fennemore Craig, a corporate defense firm. “Shkreli’s conduct is a textbook case of everything you shouldn’t do as a defendant in a criminal case.”

[The fascinating legal argument at the heart of the Martin Shkreli ‘Pharma Bro’ trial]

Since his conviction, the loquacious executive has kept an active — and combative — online presence. In addition to asking for someone to grab a strand of Clinton’s hair, he has offered investment advice and announced the sale of the only known copy of “Once Upon a Time in Shaolin,” a Wu Tang Clan album, that he purchased for $2 million in 2015.

“I hope someone with a bigger heart for music can be found for this one-of-a-kind piece and makes it available for the world to hear,” he added.

The most recent bid is for $1,001,300 — a potential loss for Shkreli.