Kenya's high court has said it would be unconstitutional to close the world's biggest refugee camp, which houses more than 200,000 people who have fled war in neighbouring Somalia.

In a ruling on Thursday, the court said a government order to shut the camp, which would have sent the refugees back to Somalia from the sprawling Dadaab camp, was illegal.

Judge John Mativo, who issued the ruling, said Kenya's internal security minister had abused his power by ordering the closure of the camp, which borders Somalia, in May last year.

According to Mativo, the order had been given without consulting the people who would be directly affected by its implications, which was a violation of Kenya's constitutional right to fair legal proceedings.

"Hence, the said decision is null and void," he ruled.

READ MORE: 'Forty percent of Somalis don't have enough food to eat'

Mativo also said that the order was discriminatory in nature and went against international treaties that protect refugees from being forced to return to persecution, adding that the Kenyan government had failed to prove Somalia was safe enough for the refugees.

Speaking to Al Jazeera, Amnesty International's Deputy Regional Director Michelle Kagari said a durable solution should be explored for Somali refugees.

"This would include, for example, exploring options for Somalis to be integrated into local communities. It would also include exploring options to increase resettlement opportunities for Somali refugees," she said.

The ruling also blocked a government decision to disband the Department for Refugee Affairs.

Amnesty International's East Africa chief, Muthoni Wanyeki, hailed the ruling as "historic".



He said: "Today is a historic day for more than a quarter of a million refugees who were at risk of being forcefully returned to Somalia, where they would have been at serious risk of human rights abuses.

"This ruling reaffirms Kenya's constitutional and international legal obligation to protect people who seek safety from harm and persecution."

The government had been planning to shut down Dadaab for more than six months. In June, Somalia's ambassador to the US criticised the plan and said it would damage relations between Kenya and Somalia.

"Many parts of southern Somalia remain under the control of al-Shabab militias and there are almost daily clashes between them and Somali government forces, and African Union peacekeepers," Al Jazeera's Mohammed Adow, reporting from the Somali capital Mogadishu, said.

"If these people [refugees] were to be repatriated back here, they will be coming back to what is essentially a warzone."

The government had denied that it would be abandoning refugees, saying it had made arrangements with the Somali government to resettle them.

In November, the closure was delayed by six months after calls by foreign nations to postpone it on humanitarian grounds.

READ MORE: Somali refugees in Kenya fear being repatriated

Kenya says Dadaab has become a hive for the al-Shabab armed group, and that it is a drain on the economy.

Some refugees have voluntarily returned to Somalia in recent months, after pressure to close down the camp spread fear of being forcibly evicted among the residents of Dadaab.