MELBOURNE, Australia (AP) — Australia’s highest court ruled Wednesday that migrants can’t be forced by law to wear electronic tracking bracelets or to comply with curfews.

The ruling is a blow to the government, whose lawyers have unsuccessfully argued that laws imposing curfews and tracking technology are justified to protect the community.

Five of the seven High Court judges ruled that the tough restrictions placed on more than 100 migrants, usually because of their criminal records, were unconstitutional because the conditions amounted to punishment. The constitution states that punishment must be imposed by judges, not lawmakers.

The restrictions were part of emergency laws hastily passed in December in response to another High Court ruling that non-citizens could no longer be detained indefinitely as an alternative to deportation. That ruling in the case of a stateless Rohingya man reversed a 28-year-old High Court precedent that allowed indefinite detention where there were security concerns.

Wednesday’s ruling means the government can no longer electronically track the more than 200 non-citizens with criminal records who were released and, for a variety of reasons, couldn’t be deported.

Home Affairs Minister Tony Burke said he would introduce legislation to Parliament on Thursday that “will allow for an adjusted process for electronic monitoring devices and curfews to be used.” He did not detail those adjustments.

“The court’s decision is not the one the government wanted — but it is one the government has prepared for,” Burke said in a statement.

“The security and safety of the Australian community will always be the absolute priority for this government,” he added.

The latest High Court case was brought by a 36-year-old stateless man, identified as YBFZ, who was born in Eritrea. His family initially fled to Ethiopia because they feared persecution in their homeland as Jehovah’s Witnesses, and they arrived in Australia as refugees in 2002.

His refugee visa was canceled in 2017 due to convictions including burglary and recklessly causing injury, part of a criminal record that extended for more than a decade. He was held in custody until 2023, when the High Court outlawed indefinite detention.

YBFZ’s lawyer, David Manne, described Wednesday’s verdict as a “major victory” for fundamental freedoms and the rule of law in Australia.

“This is an important ruling because it underscores the bedrock principle that for everyone, whether citizen or non-citizen, the government does not have the power to punish people by stripping them of their fundamental rights to freedom and dignity,” Manne told reporters.

Opposition lawmakers described the High Court decision as an “embarrassing loss” for the government.

“The effect of this decision will be that 215 dangerous non-citizen offenders including 12 murderers, 66 sex offenders, 97 people convicted of assault, 15 domestic violence perpetrators and others will be free in the community without any monitoring or curfews,” an opposition statement said.