A Long Island judge intentionally ignored the state’s controversial bail-reform law and refused to release a defendant he deemed a “menace to society,” The Post has learned.

Nassau County District Judge David McAndrews admitted in court that accused two-time bank robber Romell Nellis wasn’t charged with a “bondable or bail offense” — but still ordered him held on $10,000 cash or $20,000 bond.

“I don’t want you walking around my neighborhood,” McAndrews told Nellis, according to a transcript of the Jan. 9 hearing in Hempstead.

But McAndrew’s principled stand was short-lived, as a higher-level judge promptly reversed his order and released Nellis with an ankle monitor — only to have him cut it off and disappear.

The situation has local law-enforcement officials outraged, with Nassau Police Commissioner Patrick Ryder saying of Nellis, “He’s out there, somewhere, able to commit another crime.”

“It’s insane, when you think who we’re letting out of jail. It has nothing to do with justice reform,” Ryder said. “We’re not protecting the victims, and we’ve swung the pendulum way too far.”

Nellis, 40, was busted Jan. 8 over two bank heists in which he allegedly handed tellers notes that said, “I have a gun!” and demanded “$100s, 50s & 20s.”

The homeless ex-con made off with a total haul of nearly $9,500 from the Dec. 17 caper in West Hempstead and a Dec. 30 heist in Valley Stream, court papers allege.

At the time of the robberies, Nellis was facing sentencing in Central Islip federal court after admitting he violated his supervised release in a 2012 crack-trafficking case for which he served a seven-year prison term.

He was initially scheduled to be sentenced Dec. 16, but his court-appointed lawyer got the proceeding postponed until March 24 because Nellis was “scheduled to enter into an in-patient drug-treatment program,” court records show.

When Nellis was hauled in front of McAndrews a day after his arrest in the bank jobs, the judge acknowledged the third-degree robbery charges were covered by the law that went into effect Jan. 1.

It mandates that defendants charged with most misdemeanors or nonviolent felonies be released without bail.

“Although under [Section] 510.10, this does not qualify as a bondable or bail offense, I find this defendant to be a menace to society,” Andrews said as he ordered Nellis held on bail or bond.

McAndrews — a Republican who’s served on the bench since 2010 — also rejected arguments from Nellis’ Legal Aid lawyer, Diane Clarke, who said that “there are no allegations there was an actual gun used.”

Clarke appealed McAndrews’ move to Nassau County Judge Christopher Quinn, who followed the law and issued an order that released Nellis without bail pending his fitting with a GPS tracking device and another court appearance on Jan. 13, the Nassau County District Attorney’s Office said.

But Nellis failed to show up in court or at a follow-up hearing Jan. 15, when prosecutor Jed Painter said “we received a strap notification that he cut off his bracelet two days ago,” according to a transcript.

He’s still on the lam, according to cops.

McAndrews wouldn’t discuss Nellis’ case, but smiled before telling The Post, “You know I can’t comment.”

Neither Clarke nor Nellis’ federal defense lawyer, Jeffrey Pittell, would comment.