OPINION: The verdict is in. After three years of false starts and halting progress, the Supreme Court of Papua New Guinea has delivered judgment in a landmark case striking at the core of Australia's offshore processing regime in PNG. The ruling of the five judges is clear and unanimous: the detention of 900 men at the Australian-built facility on Manus Island is illegal, unconstitutional, and must end immediately.

The judgment confirms what we already knew. Since its earliest days, everyone from doctors to security guards warned that something was not right out at the remote, fortified facility. Australian and international observers questioned why vulnerable people were being detained there at all, why there was no oversight or transparency, and why every aspect of the detention regime was shrouded in such secrecy.

Two young men have died as a result of their illegal detention. Women and young children spent up to seven months in grossly inadequate conditions, before being brought back to Australia in mid-2013 without ever being processed. Rumours of gang rape, death threats and torture in a secret compound have proliferated, without ever being properly investigated. Meanwhile many of those who worked at the Manus detention centre – young Australians and hardened professionals alike – have returned deeply affected by what they saw offshore.

The court reminds these countries that depriving a person of their liberty is a serious act, permissible only in accordance with valid laws, and to the extent it is necessary and justified.

Asylum seekers, staff and international experts have all appealed to Australia to bring its immigration policies into line with international law, but their cries have fallen on deaf ears. In the end it took the PNG Supreme Court to step up and address the issue.

This week's judgment does not just sound the death knell for detention on Manus Island: it is a scathing indictment of how the governments of Australia and PNG have conducted themselves since 2012. The court reminds these countries that depriving a person of their liberty is a serious act, permissible only in accordance with valid laws, and to the extent it is necessary and justified.

In no uncertain terms, the Supreme Court has called on the Australian and PNG governments, jointly, to take all necessary steps to cease and prevent the illegal detention of men on Manus – not just because these countries committed to doing so under international law, but more fundamentally because that is how evolved, democratic societies with proper respect for the rights and dignity of humankind behave.

Australia now has a choice. This judgment could mean a number of things for 900 men still inside the Manus detention centre, and the handful of others "settled" in the PNG community.

An optimistic person might expect freedom – for every asylum seeker and refugee on Manus to be released from detention this week, and supported in the community while any outstanding claims are finalised and permanent solutions are found for all.

Logistically, the outcome is likely to be more complicated.

As an immediate move, the Australian and PNG governments could declare the Manus centre "open" and finish up processing while allowing the men freedom to come and go as they please. This was the approach taken on Nauru in October last year, just days before the High Court of Australia began to hear the case challenging detention on that island.

But the situation on Manus is not as simple as throwing open the front gates. The Manus centre is on an active naval base, at least half an hour's drive from the town of Lorengau, in an area where land use and ownership are charged issues. Any proposal for completely unrestricted movement in these parts would likely trigger considerable concern on the part of Manus residents and the military.

Moving the men to the transit facility closer to Lorengau is an equally fraught option. Despite the hardships of detention, the vast majority of men recognised as refugees on Manus have refused to be relocated to this facility despite the freedom and better living conditions they would gain there. Whether from fear of being attacked, or because they do not wish to co-operate with their settlement in PNG, these men have long resisted pressure to move on. They are unlikely to change their stance now.

This is not the time for mantras and responsibility shifting. The PNG judiciary has invited Australia to reconsider its approach to people seeking protection in its territory, and to bring its asylum policies into line with international law.

There is some suggestion the men could be taken to Nauru, but that country already faces significant problems with refugee integration, and would provide no long-term solution for those men found to be refugees.

Which leaves Australia as the only reasonable option. The men on Manus should be brought back to the country in which they first sought asylum. It would then be for the government to decide whether to release them into the community on bridging visas or hold them in detention, since unlike in PNG asylum seekers in Australia have no constitutional right to freedom (although they should still benefit from this right under international law).

In the wake of the judgment, Immigration Minister Peter Dutton has been quick to trot out the same old line. "No one who attempts to travel to Australia illegally by boat will settle in Australia," he declared, dismissing the ruling as "a matter for the PNG government". But this is not the time for mantras and responsibility shifting. The PNG judiciary has invited Australia to reconsider its approach to people seeking protection in its territory, and to bring its asylum policies into line with international law.

They have set the standard, now the ball is very squarely in Australia's court.

Whatever happens next is up to us.

Madeline Gleeson is a research associate at the Andrew & Renata Kaldor Centre for International Refugee Law at UNSW. Her book Offshore: Behind the Wire on Manus and Nauru is out now.

This opinion piece was first published in The Sydney Morning Herald.