The government can send African asylum seekers to Rwanda and Uganda, but may not jail for more than two months anyone who refuses to go, the Supreme Court ruled Monday.

In a unanimous decision, an expanded panel of five justices said it wasn’t convinced that the states to which Israel sends the Eritrean and Sudanese nationals are unsafe. Moreover, the state’s supervision of the process and the treatment given the asylum seekers in these countries is satisfactory, it said.

But the court refused to allow the unlimited detention of asylum seekers who refuse to go to these countries, saying this doesn’t constitute refusal to cooperate with deportation proceedings — the only legal grounds for unlimited detention — because the government promised in its agreements with these countries to send only people who go voluntarily.

Though the ruling, at the state’s request, never names the destination countries, they have long been known to be Rwanda and Uganda.

Asylum seekers who refuses to go to another country can be jailed for two months while the state tries to persuade them to change their minds, but after that they must be freed, the court said. The state can, however, bar them from living in certain cities that already have large populations of asylum seekers, it added.

The decision was written by Supreme Court President Miriam Naor, with justices Elyakim Rubinstein, Hanan Melcer, Yoram Danziger and Esther Hayut concurring.

Haaretz first reported the policy of sending asylum seekers to Rwanda and Uganda and indefinitely jailing those who refused in March 2015. The policy applied only to people being held in the open detention facility at Holot, who either hadn’t requested asylum or whose asylum request was rejected.

But the policy was never actually implemented, because two Eritrean asylum seekers and a group of human rights organization petitioned the courts against it. After the Be’er Sheva District Court upheld the policy in November 2015, they appealed to the Supreme Court.

The rights groups argued that people shouldn’t be sent to third countries when the agreements with those countries were secret and Israel’s supervision over their treatment was insufficient. Their appeal was backed by testimony from people who had gone to Rwanda and Uganda, who said they were denied legal status and weren’t allowed to stay there for long.

The state responded by submitting classified information to justify its claim that the asylum seekers were in no danger in those states.

The court did criticize the secrecy of the bilateral agreements. “I’m not comfortable with the secrecy of the agreements,” Naor wrote, though she stressed that this wasn’t sufficient grounds for overturning them.

Rubinstein, Hayut and Danziger echoed her discomfort. “Therefore, even if — with gritted teeth, in my case — we don’t disqualify a secret agreement, the court is obliged to give it redoubled scrutiny,” Rubinstein added.

He also hinted that parts of the agreements were oral rather than written. “In my view — and this is said out of vast experience in state affairs, including international agreements, and not always with the most enlightened countries — verbal provisions have little weight,” he wrote.

But Naor said that the main elements of the agreements were in writing.

Naor, whose opinion consistently referred to the asylum seekers as “infiltrators,” stressed that in principle, the government can deport them to third countries even without their consent. But because it promised in these agreements to send only people who go willingly, it must keep its promise, she said.

The reason for this promise is classified. But it appears to be because Rwanda and Uganda refused to accept involuntary deportees.

By law, people who refuse to cooperate with deportation proceedings can be jailed indefinitely, Naor continued. But since people sent to these third countries aren’t involuntary deportees, this law doesn’t apply to them.

Therefore, she wrote, such a person can be held for no more than 60 days.

“During this time, it’s permissible to try to persuade him through means that don’t infringe on his free will, or to try to find other ways to deport him against his will,” she wrote. “Similarly, the state can consider alternatives to deportation, including the alternative of restricting his place of residence.”

But should the state reach agreement with a country willing to accept involuntary deportees, it would be free to implement this agreement, Naor added. And in that case, someone who refused to leave could be jailed indefinitely.

Both Rubinstein and Danziger backed Naor’s proposal to restrict asylum seekers’ place of residence. Danziger noted that Germany and other European states mandate geographic dispersal for asylum seekers, and this policy has been upheld by European courts.

But Rubinstein was emphatic that the state couldn’t send anyone to a third country unless he gives “literal consent, not the ‘force him until he says yes’ kind.”

Though the court scrutinized both existing bilateral agreements, the ruling focused on the agreement with Rwanda, where the state had sought to send the two petitioners. This agreement’s secrecy requires the state to give people sent there “detailed information, in a language they understand, about all the commitments the third country has made regarding them,” Naor wrote.

Moreover, she said, the court must supervise the agreement’s implementation and ensure that the deportees actually receive all their rights in the third country. Hayut agreed, writing, “The court must serve as the deportees’ mouth and eyes.”

The original petition was filed on behalf of the two Eritreans by attorneys Anat Ben-Dor and Elad Cahana of Tel Aviv University’s Refugee Rights Clinic. It was then joined by the Hotline for Refugees and Migrants, the Association for Civil Rights in Israel, the African Refugee Development Center, Physicians for Human Rights, ASSAF — the Aid Organization for Refugees and Asylum Seekers and Kav LaOved.

“We welcome the court’s decision that asylum seekers cannot be held indefinitely in order to pressure them. Today’s decision sidestepped a draconian order and a situation in which noncriminals are imprisoned,” the rights groups said in a statement issued after the ruling. “Asylum seekers are fleeing Israel in thousands due to abuse by the authorities, even without added pressure against them through imprisonment.”

Interior Minister Arye Dery welcomed the decision that “infiltrators” could be sent to third countries, but criticized the court for allowing only voluntary deportations. “The decision not to allow the state to deport infiltrators against their will is very problematic,” he said. “We have to care for the citizens of Israel, the residents of south Tel Aviv and other cities where residents’ lives are unlivable.”

But Mutasim Ali, a Sudanese national who become one of the leaders of Israel’s asylum-seeker community and was later recognized as a refugee by the state, called the ruling “a complete violation of human rights against people who have escaped persecution and torture. I don’t see any logic in revoking their freedom for two months due to their refusal to be deported. We will continue to fight for fair policies that protect the rights of all residents of the neighborhood: refugees, asylum seekers and [Israeli] citizens.”