TRIPOLI, Libya - Around a thousand Egyptians, Jordanians and Filipinos were boarding a passenger ferry Sunday to escape continuing instability and shortages in the battered Libyan capital.

A week after rebels swept into Tripoli and toppled the regime of Moammar Gadhafi, the city is more secure but remains wracked by shortages and instability.

Even as these leave, thousands more, many from sub-Saharan Africa, remain stranded and occasionally subject to abuse by rebel forces.

"The whole situation is worrisome, and daily life is very difficult, so we want to leave until daily life returns to normal," said Abu Obeidi Labib, an Egyptian documentary filmmaker who has lived in Tripoli for 32 of his 35 years.

He wants to leave for the sake of his young daughter, playing around his feet, and his pregnant wife.

"We will return after it calms down, but the (NATO) bombardments upset my child, and now my wife can't stand all the shooting," he added. They plan to go back to the quiet Egyptian city of Aswan, deep in the south, until she has given birth.

The Tripoli port was filled with people scrambling to get on the ferry, which normally plies the waters between Turkey and Lebanon but is now being used by the International Organization for Migration.

It is the group's second trip. They plan several more to help the foreigners stranded in Libya, especially those from countries too poor to send their own ships.

Othman Bilbaisy, the senior operations officer for the IOM, estimated a thousand foreigners, most of them Egyptians, were expected to leave Sunday.

"The number varies every day because when people feel safer, they probably decide to stay," he said, explaining how difficult a decision it is for them. "Most people are migrants and they come to make money, so they can't afford to go back empty handed."

He said the next boat would try to evacuate more sub-Saharan Africans, who are often now targeted by rebels because of Gadhafi's tendency to hire mercenary fighters from their countries.

The majority of the crowd Sunday were young Egyptian day labourers from poor rural towns.

One group boasted that they were using the ship as a free ride home for the upcoming Eid holidays, marking the end of the holy month of Ramadan, and would be returning on the days-long route overland through eastern Libya.

Libya, a country of just six million, used to employ up to a million foreign workers, hundreds of thousands of whom fled when the uprising against Gadhafi started in February.

They range from construction workers and hotel cleaners to highly paid professionals, like Mohammed Idris, a 27-year-old Jordanian working as an embryologist at a fertility clinic. On Sunday, he was waiting on the quay to crowd onto the ship with the Egyptian labourers.

With his slight frame, wispy beard and glasses, he seemed out of place in a city overrun by gun-toting rebels flashing victory signs and shooting in the air.

"It will take time to return to normal. The educated people with logic and reason need to come back so that things can calm down again," he said.

While many of those leaving expressed some disquiet about the loosely organized bands of armed men roaming the city, Libya's migrant black African migrant workers have the most to fear.

On Sunday, in a neighbourhood on the outskirts of the city, rebels apprehended a dozen black men and accused them of being mercenaries in Gadhafi's army. They were occasionally punched before one of the rebels was able to convince his comrades the men were just migrant workers.

The men came from a nearby abandoned farm, where around 300 Africans who had not been able to flee during the war had gathered, including some from Nigeria, Sudan, Somalia and Ghana.

They had only two spigots that sporadically provide brackish water. Most sleep on simple mats outside.

William Osas, a 32-year-old Nigerian, said many of them were once farm workers. They fled the fighting and have been living there for months, often receiving food from the black soldiers in Gadhafi's army.

Now the rebels have told them they must get out.

"They told us that we have two days to leave here, and if we don't leave they'll kill us all," he said. "They said that Gadhafi uses blacks and that we are with Gadhafi, but we don't know anything about that."

He said all they want now is to return home.