Refugees arrive in 2011 at sprawling Dadaab refugee camp in northeastern Kenya. (Dai Kurokawa/EPA)

A Kenyan court ruled Thursday against government plans to close the world’s largest refu­gee camp, which officials have claimed also serves as a foothold and recruiting ground for Islamist militants.

The court’s decision offers some breathing room to the mostly Somali refugees in the sprawling Dadaab camp, which holds hundreds of thousands of people fleeing unrest in Somalia.

It also could force Kenyan authorities to draft another strategy for dealing with the camp, which the government insists is infiltrated by Islamist militant groups such as al-Shabab. Kenya has never made public any evidence to back up its assertions.

Meanwhile, human rights groups and others have denounced Kenya’s plans, saying it would put refugees’ lives at risk by sending them back.

Al-Shabab, which has carried out attacks in Somalia for years, also has struck in Kenya, which sent troops to Somalia in 2011 to fight the militants. The attacks include a September 2013 rampage at the Westgate mall in Nairobi that killed 67 people, and a 2015 massacre at Garissa University in northeastern Kenya that killed 148 people, mostly students.

The immediate effect of the ruling is a halt to an ongoing process of repatriating Somali refugees to their war-torn country.

At Dadaab’s peak in 2011, its population surged well above 500,000, and it was dubbed the world’s largest refugee camp. Last year, U.N. officials said the number had fallen to 350,000. Kenyan officials give a lower estimate.

In his ruling, High Court Judge John Mativo said the decision to repatriate refugees was unconstitutional and “an act of Somali refugees persecution.” The judge also said that Kenyan Interior Ministry officials “acted beyond their powers in issuing directives to close down the camp.”

One refu­gee in Dadaab, Fatma Ahmed, called the court ruling “good news . . . but not the best.”

“This will give us more time to plan what’s next,” said Ahmed, a 20-year-old mother of two children. “At least we do not have to go back to Somalia, but that means we have to remain here in the camp for quite some time because it will now be almost impossible to go to the U.S.”

Many refugees had hoped to reach the United States, which has Somali communities in several states. But the Trump administration’s travel ban — now in limbo as a legal challenge plays out — included Somalia among seven majority-Muslim nations whose citizens are temporarily barred from entering the United States.

Last May, the Kenyan government cited security concerns as it announced it would close the camp in northeastern Kenya near the Somali border.

The court decision came a day after a former Somali prime minister and dual U.S. citizen, Mohamed Abdullahi Farmajo, was announced as the winner of the country’s long-delayed presidential election.

“The news hasn’t reached most people yet. People are still celebrating the election of the new Somali president,” said Hassan Mohammed, a refu­gee. “By tomorrow, when everyone has the news, there should be more celebrations.”

Close to 10,000 refugees have been repatriated so far since late 2013 following the signing of a three-party accord by Kenya, Somalia and the U.N. refu­gee agency.

Human rights groups have opposed closure of the camp. Last year, Human Rights Watch called the repatriation of Somalis from Dadaab a violation of international refu­gee standards.

A statement from Human Rights Watch on Thursday said the refugees had faced “months of anxiety” because of the planned closure and “increasingly restricted asylum options and the recent U.S. administration suspension of refugee resettlement.”

It added, “The court’s judgment offers Somali refugees a hope that they may still be have a choice other than returning to insecure and drought-ridden Somalia.”