But for workers from countries that would normally need visas to enter Egypt, the border has become a sea of red tape. Stacks of handwritten visa applications sit in a packed immigration office, waiting for embassies to sign off on their citizens. The Egyptian government will allow entry only to those migrants with a plane ticket, so the International Office of Migration has become a harried travel agency searching for spare seats on flights for places like Guinea and Mali.

“We are not sure what is happening,” said Jahidul Islam, 24, who was working at a Hyundai-owned power plant near Benghazi, Libya, making $3,000 a year. He fled a week ago after his camp was attacked by gunmen, he said, but he was still waiting to find out from the Bangladeshi Embassy what was happening. He complained of hunger, as did others. One Bangladeshi official at the border said that an emergency coordinator for the I.O.M. had been trying to arrange visas for three straight days and nights.

Migrants had many reasons for leaving. Some said their companies in Libya had shut, leaving them stranded. Others said they were just afraid. Bassiro Cande, a 41-year-old from Guinea, was among several people who said they had been either threatened or beaten in recent days, as rebels mistook them for African mercenaries whom Col. Muammar el-Qaddafi had brought in from countries to the south.

“Before only the police would beat us, now the people did as well,” Mr. Cande said. “People thought we were fighting for Qaddafi, but we were innocent.”

Asammoah Solomon, 32, from Ghana, who was waiting to board a bus, said, “We became enemies to the Libyan people.” He said a crowd in Benghazi had rushed at him and three other Ghanaians with sticks, “so we ran.”

On Monday, the United Nations said it flew out 216 Guineans, 15 Moroccans and 35 Bangladeshis. On Tuesday, Ghana sent buses for hundreds of its citizens, and on Wednesday, 174 people will be put on a charter plane to Dhaka. So far, the United Nations and the Egyptian Army are the only organizations that seem to be helping.

Only one group was being turned back at the border: Palestinians, said Mai Mahmoud, a United Nations worker in Salum. Egyptian authorities had returned 33 Palestinians to Libya on Tuesday, including children, and two more families were being threatened with expulsion.

“Obviously we are very concerned about this,” Ms. Mahmoud said, “and we are going to follow up with the authorities.”