Massachusetts' high court has ruled in favor of a Somali man in a case that tested efforts by Boston's top prosecutor to protect immigrants from being deported for non-violent crimes.

Supreme Judicial Court Justice David Lowy ruled Tuesday that a lower court judge must honor Suffolk County District Attorney Rachael Rollins' decision to drop a misdemeanor larceny charge against 28-year-old Osman Bilal.

Rollins said Bilal, who pleaded guilty and served a year of probation nearly a decade ago, had paid his debt to society and shouldn't be punished further.

"When an individual has worked so hard to take accountability for their actions and turned their life around, I will not sit idly by when cruel and extreme collateral consequences impede their ability to move beyond their past," Rollins said in a statement. "No one is their worst moment."

Bilal, whose family had arrived in Massachusetts as refugees in 2007, said he was "speechless" in a statement provided by his lawyer.

"This has been a long and tortured road for Mr. Bilal and there is now finality, which also includes justice," Kelly Cusack, his lawyer, added.

Rollins' office had recently sought and received a new trial for Bilal, then promptly dropped the charges, which stemmed from his 2011 arrest for stealing jewelry from a Boston street vendor. The legal maneuver was meant to help Bilal renew his green card and avoid deportation.

But Boston Municipal Judge Michael Coyne reversed his order granting the new trial and reinstated Bilal's conviction just days after initially ruling on the case.

Coyne complained that Bilal's lawyers and Rollins' office had "intentionally misled" the court. Rollins petitioned the high court, arguing that Coyne overstepped his authority in reversing the decision.

In legal filings, Rollins' office said prosecutors made it clear to Coyne that they sought to vacate Bilal's conviction so he could avoid "extreme and unjust collateral consequences from cruel federal immigration laws."

According to Rollins office, Bilal's family fled Somalia when he was an infant. He lived for years in a refugee camp in Saudi Arabia and later in Syria before coming to Massachusetts and later becoming legal permanent resident.

After his 2011 arrest, Bilal turned his life around and is now a sous chef at a restaurant in Boston's popular North End, supporters said in letters filed with the court.

Lowy, in his order Tuesday, said there was "sufficient basis" to grant Bilal a new trial, noting Coyne had available to him "the defendant's case file, an explanation of the significant immigration consequences of the defendant's plea, and DA Rollins' new policy."

He also noted that declining to prosecute a case is at the discretion of prosecutors, not the court.

Coyne declined to comment through a court spokeswoman.

Rollins, a Democrat, was elected Boston's top prosecutor in 2018 on a campaign promise not to prosecute nonviolent offenses like drug possession, shoplifting and trespassing that she says disproportionately hurt poor and black communities.

Among the new policies she also instituted was reviewing any cases where defendants were seeking to have their convictions vacated due to "unjust immigration consequences."

Rollins has had other prominent clashes with the judiciary, most recently with her decision not to prosecute many counter protesters arrested for minor infractions at a "Straight Pride Parade" in Boston last year.