Martin Shkreli apologized Tuesday for a bizarre Facebook post about Hillary Clinton's hair that threatens to land him in jail , saying he used "poor judgment" with "my awkward attempt at humor."

Shkreli's mea culpa was attached to a letter that his lawyer sent a judge asking her not to revoke the $5 million release bond of the bombastic ''pharma bro.''

And it came just 24 hours before Wednesday's scheduled hearing on a request by prosecutors to lock him up, and just days after Shkreli taunted those prosecutors and their request online.

Shkreli, 34, last week encouraged followers of his Facebook page to grab samples of Clinton's hair from her head and said he would pay them $5,000 per sample.

The post sparked an inquiry from the U.S. Secret Service – and led federal prosecutors to ask Judge Kiyo Matsumoto to jail Shkreli as a potential danger to the community.

"His recent public conduct demonstrates that he cannot meet his post-trial burden to show, by clear and convincing evidence, that he does not pose a danger to the community," the prosecutors from the Eastern District of New York wrote.

Prosecutors noted that Shkreli pulled this latest stunt just weeks after being convicted of three securities fraud-related counts in Brooklyn federal court, crimes for which he has yet to be sentenced.

"I wanted to personally apologize to this Court and my lawyers for the aggravation that my recent postings have caused," Shkreli wrote in the letter.

"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."

"I used poor judgment but never intended to cause alarm or promote any act of violence whatsoever," he wrote, adding that he had quickly amended his post to make clear he had just been joking.

"I want to assure Your Honor that I am not a violent person, have never personally engaged in any violent behavior, nor have I ever intentionally encouraged anyone to do so," Shkreli wrote.

"I apologize for my behavior and ask you respectfully not to change my bail status so that I may continue to assist my attorneys to prepare for my sentencing."

Last week, Shkreli took a very different stance toward prosecutors after they complained to Matsumoto about his Clinton hair bounty.

In a Facebook post, he wrote: ''F--- the government. I will never kiss their ring or snitch. Come at me with your hardest because I haven't seen anything impressive yet.''

In the past several days, however, Shkreli has spoken to his lawyers, and apparently changed his tune, according to a letter from his high-powered defense attorney, Benjamin Brafman.

Brafman, in that letter to Matsumoto, wrote, "While we do not condone Mr. Shkreli's comment, his constitutionally-protected political hyperbole does not rise to the level of making a 'danger to the community' when he is not and has never been considered to be a danger."

Brafman said that Shkreli should not be jailed because he "never intended any harm or violence."

The lawyer disputed prosecutors' contention that comments Shkreli made online about Clinton and a journalist, Lauren Duca, constitute an escalate pattern of threats,

Brafman suggested that Shkreli, who claims to be a supporter of President Donald Trump, was engaging in "political hyperbole" or "satire" in his comments about both women.

Brafman cited the fact that comedian Kathy Griffin was not prosecuted after she posted online a photograph of herself holding what appeared to be the bloody, severed head of Trump.

"Another example of political hyperbole is when President Donald Trump, as a candidate, caused a controversy last year by implying that 'Second Amendment people' could prevent former Secretary Clinton from abolishing their right to bear arms."

Read Shkreli's letter: