Parts of Dadaab, the world's largest refugee camp, in northern Kenya. (File photo: Ben Curtis/AP)

The repatriation of some 400 000 Somali refugees back to their home country was cancelled on Thursday after a High Court in Nairobi declared the operation illegal.

The High Court in Nairobi has quashed the government's plan to close down the Dadaab refugee camp.

In a ruling likely to be hailed by international aid agencies as well as the victims themselves, Justice John Mativo said that Interior cabinet secretary Joseph Nkaissery and principal secretary Karanja Kibicho acted beyond their powers in issuing the directive to close down the Daadab refugee camp terming the move Mativo was 'an act of Somali refugees persecution'.

The court also declared the repatriation of refugees unconstitutional and described it as discriminative. Last May, Nkaissery announced the government was shutting down the camp by November 2016, citing security, environmental and economic concerns, and accused the international donors of doing little to support refugees, sparking protest from various NGOs and civil society organisations.

Announcing the closure Nkaiserry, a retired military general, said the government would close the Dadaab refugee complex – a series of camps in North Eastern Kenya that house more than 300 000 mostly-Somali refugees – and that it wished to deport 150 000 Somali refugees by the end of 2016. Nkaisserry alleged that the camps had become hosting grounds for al-Shabaab, a militant group affiliated to al-Qaeda that are based in neighbouring Somalia but are believed to have a presence in Kenya.

The group has claimed responsibility for dastardly attacks on Kenyan soldiers operating in Somalia under the Amisom flag. Last January, al-Shabaab mounted a vicious attack in El Adde, where more than 100 Kenyan soldiers were killed. On the anniversary of that attack, al-Shabaab staged another bloody attack on the Kenyan contingent based in Kuliboy, Somaila killing almost 60 soldiers.

When Nkaiserry made the announcement last year, the UN Refugee Agency called on the Government of Kenya to reconsider its recent announcement that it intends to end the hosting of refugees. “It is with profound concern that UNHCR takes note of this announcement,” spokesperson Adrian Edwards said. “For almost a quarter of a century, Kenya has played a vital role in East Africa and the Horn of Africa in providing asylum to people forced to flee persecution and war.”

Edwards noted that the safety of hundreds of thousands of Somalis, South Sudanese and others has hinged on Kenya’s generosity and its willingness to be a leading beacon in the region for international protection.

“UNHCR has been, and will continue to be, in touch with the Kenyan government to fully understand the implications of its statement,” he said. “We recognise that Kenya has played an extraordinary role over many years as one of the world’s frontline major refugee hosting nations, and that inevitably this has had many consequences for the country and its population.”

The Kenyan government has said that the Somalia-based al-Shabaab Islamists have hideouts in Dadaab, and that an al-Shabaab attack at Garissa University College in northeast Kenya last April, which killed 148 people, was planned from the camp.

The UNHCR, Kenya, and Somalia signed a tripartite agreement on the “voluntary repatriation” of “Somali refugees” in 2014, but the process has been slow until this year.

Human Rights Watch also joined the fray accusing Kenya of betraying its commitment to international treaties guaranteeing rights and safety of refugees. “Kenya’s repatriation program for Somali refugees, fuelled by fear and misinformation, does not meet international standards for voluntary refugee return. Many refugees living in Kenya’s sprawling Dadaab camp, home to at least 263 000 Somalis, say they have agreed to return home because they fear Kenya will force them out if they stay.

During an August 2016 visit to Dadaab by Human Rights Watch, refugees described intimidation by the Kenyan government, silence over alternative options that would allow them to remain in Kenya, inadequate information on conditions in Somalia, and a $400 UN cash grant they would forfeit if they were deported later this year. The refugees said that these factors were prompting many camp residents to return now to Somalia, where they face danger, persecution, and hunger,” HRW said in a statement.