CANBERRA, Australia (AP) — Australia's highest court on Wednesday upheld a law that can keep extremists in prison after they have served their sentences.

Five of the seven High Court judges dismissed a constitutional challenge by convicted terrorist Abdul Benbrika who remains in a Victoria state prison despite his 15-year sentence expiring in November last year.

The 60-year-old Muslim cleric is the first extremist to be incarcerated by a so-called preventative detention order based on an anti-terror law created in 2017.

Australia introduced the law as the number of extremists held in prisons on terror-related convictions was increasing and public concerns grew that some of the most-feared radicals were nearing the end of their sentences.

Benbrika was convicted in 2009 of being the Melbourne leader and member of a terrorist cell.

He was one of 12 men in Melbourne and Sydney convicted of terror-related offenses involving planning of attacks against various targets including the then-prime minister and a Melbourne Australian Rules Football match. No attack took place.

Under the 2017 law, prisoners convicted of terror offenses can be held for a further three years beyond their sentences if a judge grants a federal government application for a detention order.

Such an order can be renewed after three years if the prisoner is considered to continue to pose a public threat.

Benbrika’s lawyers had argued that his continuing imprisonment was unlawful because involuntary detention was considered in Australia to be punishment for a crime except under exceptional circumstances, such as a prisoner with a mental illness or an infectious disease.

The majority of judges ruled that protecting the community from a terror crime amounted to exceptional circumstances.

Algeria-born Benbrika faces deportation on his release from prison. In November last year, he became the first person to be stripped of Australian citizenship while still in Australia.

The first person to be stripped of Australian citizenship under an anti-terror law created in 2015 was Khaled Sharrouf in 2017.

Sharrouf was a convicted Sydney member of Benbrika’s cell who was reported killed by a drone strike in Syria while fighting for the Islamic State group six months after he lost his citizenship.

Sharrouf gained international notoriety in 2014 when he posted online a photograph of his 7-year-old son clutching the severed head of a Syrian soldier.

Then-U.S. Secretary of State John Kerry described the image during an Australian visit as “one of the most disturbing, stomach-turning, grotesque photographs ever displayed.”