JERUSALEM - Israel's supreme court has ordered the government to allow five critically ill Gazan women to cross into Israel for medical treatment after they were refused over alleged links to Hamas, NGOs said Monday.

The women were rejected under a policy preventing "first-degree relatives" of the Palestinian Islamist movement which rules the Gaza Strip from entering Israel, the Israeli rights groups involved in the case said. The policy aims to pressure Hamas to return the remains of two Israeli soldiers it is believed to be holding, the organisations said. Most of the five women have cancer, according to the statement issued by Gisha, Adalah, Al Mezan and Physicians for Human Rights-Israel.

The court's ruling on Sunday said they do not constitute a security risk and that refusing their entry to Israel was illegal because they were in "danger of death". They have sought treatment at hospitals in Israeli-annexed east Jerusalem that is unavailable in Gaza, the NGOs said.

Israeli authorities had authorised them to cross and travel for treatment in the occupied West Bank or abroad.

But the women said that effective treatment was not available in the West Bank and the cost of care abroad was too expensive.

The original petition was for seven women, but Israel earlier said it had mistakenly identified two as relatives of Hamas members.

The NGOs said the ruling would have wider implications.

"The court rightly dismissed the Israeli defence minister and cabinet's outrageous decision to use patients in critical condition as bargaining chips, and ruled that this policy contradicts the most basic of values," they said.

It condemned the policy as "a new and shameful low in Israel's collective punishment of Gaza residents".

READ MORE: The true north

The same groups said earlier this month that the number of Gazan exit permits denied by Israel due to a close family member's alleged connection to Hamas had soared.

Some 833 exit permit applications by Gazans were denied on those grounds in the first quarter of 2018. compared to 21 during the whole of last year, they said.

Israel controls all access to and from the Gaza Strip apart from the enclave's crossing with Egypt. Hamas has fought three wars with Israel since 2008.

Under an Israeli blockade for more than 10 years, Gaza lacks infrastructure and key medical equipment. Many patients seek to travel elsewhere for treatment.

On Monday, Israel reopened its only crossing for people with Gaza, a week after shutting the Erez post over violence along the border with the Palestinian enclave.