A self-proclaimed Brooklyn anarchist sent to jail for refusing to testify in the 2008 bombing of a Times Square military recruiting center caught a break on Tuesday when a fed-up federal judge granted his release — because he was tired of him enjoying being a “martyr.”

“The court finds it more likely that [Gerald] Koch will only derive increasing grim self-satisfaction from his position,” Manhattan federal Judge John Keenan wrote in his 20-page opinion. “The more unstable he gets, the more he will be presented as a martyr and perceive himself as such. Koch has already decided that this type of notoriety is more valuable than his health and freedom in the short run.”

“The Court sees no indication that Koch’s doctrinaire fever will break in the foreseeable future,” the judge added. “Consequently, there is no realistic possibility that he will choose to testify before the grand jury.”

Koch in May declared Koch, 24, in contempt of court and banished him to Metropolitan Correction Center for snubbing two FBI subpoenas to testify before a federal grand jury investigating the bomb plot.

Koch claims to know nothing about the unsolved attack but won’t answer questions because he says prosecutors are on a “fishing expedition” to find out about his personal beliefs and political associations.

Prosecutors believe he was inside a bar when some patrons discussed bombing the recruiting center.

Koch is a senior at The New School with one semester left until graduation.

The New School Free Press on Tuesday night linked to a Facebook posting from Koch’s mother in which she said, “My Jerry called collect from a payphone in the lobby of the courthouse. They just took off his handcuffs and said ‘you’re free.’ In prison sweats and cotton slip ons, he ran six blocks in 15 degree cold to his attorney’s office. I am crying tears of joy.”

No arrests were ever made in the Times Square bombing that resulted in no injuries or serious damage.