SAN FRANCISCO (BCN) — A homeless man who couldn’t afford $330,000 bail while awaiting trial on burglary and auto theft charges has been released from a San Francisco jail on the order of a federal judge in the city.

James Reem, 53, was arrested in San Francisco and charged in San Francisco Superior Court in July and was held in jail until he was freed Tuesday following the order by U.S. District Judge Charles Breyer.

READ MORE: Twitter To Pay $809 Million To Settle Class Action Lawsuit Brought By Investors

Breyer said in a decision issued Monday that Reem wasn’t given a constitutionally adequate bail hearing when a San Francisco Superior Court judge set his bail at $330,000.

Breyer said the high bail resulted in the equivalent of pretrial detention, and said such custody should be allowed only when a judge bases a detention decision on evidence that meets “minimum standards of reliability” showing that a defendant is a danger or a flight risk.

After the high bail was set in Superior Court, Reem appealed in the federal court system through a habeas corpus petition.

In an earlier ruling in the case, Breyer said the bail amount violated the U.S. Constitution’s guarantee of equal protection because “Reem would have gone free for no other reason than his wealth, had he been able to
obtain the money.”

READ MORE: KPIX Original Report: SF Mission Bay Sidewalks Sinking But City Won't Fix 'Private Property'

The case has gone back and forth between Breyer’s court and the Superior Court three times. In his most recent ruling in December, Superior Court Judge Garrett Wong said Reem was a flight risk because of multiple parole and probation revocation hearings and because he previously failed to appear for at least two bench warrants.

But Breyer said Reem’s attorneys produced evidence in December that supported Reem’s claim that he made 23 court appearances and missed two others because he was in custody in connection with other cases.

In the face of that evidence, Wong “relied on a bare assertion by the state that Reem willfully neglected to attend previous hearings” and denied Reem due process of law, Breyer wrote.

San Francisco Public Defender Jeff Adachi, whose office represented Reem, said in a statement, “Unfortunately, San Francisco judges just aren’t getting that they are violating our clients’ rights by failing to meet minimum federal constitutional requirements in bail hearings.”

MORE NEWS: Motorcyclist Airlifted To Hospital After Crash Near Bethel Island

© Copyright 2018 CBS Broadcasting Inc. and Bay City News Service. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.