A humanitarian crisis is rapidly emerging as refugees stream out of Libya. Already more than 150,000 people have crossed into neighbouring Egypt and Tunisia. An estimated 40,000 people are gathered on the Libyan side of the border, waiting their turn to cross.

The majority of the refugees leaving Libya — as opposed to internally displaced — appear to be foreign nationals. Of the 70,000 who have crossed into Egypt only around 3500 were Libyans. This figure initially seems surprising, but given the massive numbers of migrant workers who live in Libya it should not come as a shock.

Libya is home to an estimated 1 million illegal immigrants. This in a country with an official population that totals only around 6.5 million. The oil-rich nation with a traditionally sparse desert population has followed the path of many of the Gulf states in importing skilled and unskilled labour with almost equal enthusiasm. The result is a country with surprising ethnic diversity and deep racial resentments.

The vast majority of Libya’s foreign nationals are Egyptian or sub-Saharan African. But Libya is also home to other groups, including more than 60,000 Bangladeshis, 30,000 Filipinos and 30,000 Chinese. What these disparate migrants are doing while their adopted country disintegrates around them is currently far from clear.

Many Egyptian nationals have understandably taken the events of the last week as a queue to return home — but tens of thousands who work in Eastern areas of Libya return to Egypt is not an option. These Egyptians have joined the throng scrambling towards Tunisia, and many are now stranded in a third county, still reeling from its own revolution.

The UNHCR is in the process of setting up instant camps — including one just inside the Tunisian border capable of holding 20,000 people — but the numbers are likely to be overwhelming. Indications so far suggest that the Tunisians revolutionary committees are coping well with the situation — but as Tunisia faces its own demons now is hardly the time for an influx of refugees. They will need help.

Australia yesterday announced an additional AUS$5 million to fund UN programs related to the crisis. This is in addition to $1 million already channelled through the International Red Cross. The UK has already begun an ambitious airlift of Egyptian refugees from Tunisia back to Cairo.

But while frantic measures have been made to evacuate western nationals — including British SAS raids — migrant workers from countries such as Eritrea have not been so fortunate.

Sub-Saharan Africans working or seeking asylum in Libya have been frequent targets of violence and abuse since protests began. In part, this is the result of underlying racism. But in many cases these African migrants are being mistaken for foreign mercenaries in the pay of Gadaffi.

Details are sketchy, but a significant number of soldiers of fortune are clearly operating in Libya. Just how many and in what capacity is harder to evaluate. Broadly speaking these foreign forces can be divided into three categories; those fighting for political reasons, those fighting strictly for cash, and those who have been pressganged.

For the last 40 years paramilitary groups have been welcomed to train within Libyan territory — from the IRA, to the PLA, and just about any revolutionary group in Africa, thousands have taken up the offer. Reports suggest that some of these fighters have been incorporated into Libyan security forces.

However it is more strictly mercantile mercenaries who are causing the biggest problems for Libya’s migrant workers. The total numbers of these soldiers are likely quite small. But the countries which have thus far been associated with Gadaffi’s guns for hire — Chad, Nigeria, Niger, Ethiopia — are also regions that supply much of Libya’s itinerant workforce.

Yesterday there were at least two cases of innocent migrants being lynched in Benghazi after suspicion of mercenary activity. Many more fear a similar fate.  A UN report released on Wednesday suggested up to 100,000 sub-Saharan Africans may flee Libya into poverty stricken Niger in coming weeks. What awaits them may not be much better than what they are leaving.