Kenya's High Court has ruled that the government cannot unilaterally shut down the world's largest refugee camp, the sprawling Dadaab facility near the border with Somalia.

In a ruling hailed as historic by rights groups, judges said it was unconstitutional for Kenya's interior minister to order the closure of the camp, which houses a quarter of a million people.

"The government's decision specifically targeting Somali refugees is an act of group persecution, illegal, discriminatory and therefore unconstitutional," High Court judge John Mativo said in a ruling.

Amnesty International, which is among the groups that challenged the government's actions, said the closure of Dadaab would have left more than 260,000 Somali refugees with nowhere to go.

Muthoni Wanyeki, Amnesty International’s regional director for East Africa, 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.

"Stopping the imminent closure of Dadaab refugee camp is an essential first step in respecting and protecting refugee rights in Kenya. Now Kenya and the international community must work towards finding alternative solutions for refugees including local integration options."