Two women and a teenage boy, part of a group of 21 Eritrean migrants camped out next to the country’s border with Egypt, have been given permission to enter Israel.

The other 18 men in the group will reportedly reenter Egypt as part of the deal. Egypt has said it will not harm them.

The 21 migrants, reportedly looking for work, had been stuck at the border for eight days, with Israel refusing to allow them in or to allow groups to approach them to provide humanitarian aid.

Earlier Thursday, the High Court of Justice said it would wait until Sunday to decide on a petition to compel the defense and interior ministers to grant the group permission to enter the country.

On Wednesday, Interior Minister Eli Yishai said the group would not be allowed into Israel.

Commenting on the decision to allow the three Eritreans to enter, Prime Minister Benjamin Netanyahu said Israel would continue to bolster efforts to stop the entrance of African migrants.

“Everyone must understand that Israel isn’t yet another destination for infiltrators. We are determined to stop the flood of infiltration which has been taking place here,” he said in a statement. ”We will act even more strongly against the infiltrators’ employers and continue our efforts to return the migrants to their countries of origin.”

The group, one of many that try to make it to Israel, made it past the first of two security fences but was stopped before crossing into Israel. The Eritreans were then stuck between the two barriers. Too scared to backtrack through Sinai, they sat in the sun without food or water save for a few beverages they were given by Israeli soldiers.

Attorney General Yehuda Weinstein ruled Wednesday that Israel “has no legal obligation” to let the group of migrants enter beyond the fence, Netanyahu’s office said in a statement. “According to international practice and precedence, the fence is the actual border, so whoever has not crossed it is not [located] in Israeli territory, and does not have an automatic right to enter.”

The statement further added that there is no international confirmation that the migrants are persecuted or facing grave danger in Egypt, and that Israel is therefore not obliged to let them through.

Human rights groups had claimed Tuesday that the territory the migrants are in is technically Israel. The Association for Civil Rights in Israel stated: “Israel has every right to build a border fence, but this fence does not exempt it from its duties.”

The UN’s High Commissioner for Refugees’ representative in Israel, William Tall, expressed concern for the fate of the migrants, and urged Israel to allow them in.

Tall said that Israel’s commitment to international conventions on refugee rights obligates it to allow the migrants to enter the country and review their eligibility for refugee status.

“It is harder for me, more than anyone, to see these pictures, and send families back to their homelands,” Yishai said during an interview with Army Radio Wednesday morning. “But I am the one who has to make the difficult decision. If I have to choose between them and good of the state, its civilians, and its security, I choose that there be a fence, and that they [the migrants] don’t enter.”

Yishai said he hoped the group would return to Eritrea.

He touted the partially completed fence along Israel’s 240-kilometer (150-mile) border with Egypt as responsible for preventing a million refugees — he then corrected himself to say migrant workers — from entering Israel.

Meretz party leader Zahava Gal-On, on her Facebook page, criticized Yishai’s “brutal, xenophobic” decision not to allow the migrants into the country. She said the minister’s move was “not only immoral but also illegal under international law, which determines that refugees who are persecuted in their country, and who face danger if they return there, can be granted political asylum.”

Earlier Wednesday, Gal-On had called on Yishai to allow the group to enter Israel and to reassess their status.

Groups of activists traveled to the Israeli-Egyptian border Tuesday night and Wednesday morning to deliver food and water to the group. They claimed they were not allowed to deliver the goods to the Eritreans personally — but were promised by the IDF that soldiers would distribute the items.

“They [the IDF] were determined not to let us pass, and threatened to arrest us — and they meant it. In negotiations with the soldiers, the battalion commander proposed we leave the food behind, and that they would deliver it to the migrants,” one activist told Haaretz.

Media reports suggested that soldiers have complained of inadequate direction from their seniors on how to handle the situation.

Last month, in a similar incident, a group of African migrants was transferred to a detention facility for humanitarian reasons after being stuck between Israel and Egypt for four days.

Israel is believed to be considering a forced repatriation of Eritrean asylum-seekers back to their home country — a move that has been criticized by human rights groups but is nonetheless acceptable under international law because Israel and Eritrea have diplomatic ties.