TRIPOLI, Libya -- Maxim Kwadwo set up his sales cart with cold cream and hair oil in a narrow alley in the decayed old city of Tripoli to avoid the competition on the bigger streets nearby. A group of young Libyans came by and complained that he was making it hard for pedestrians to pass. They called him obscene names, slapped him and told him to go back to Ghana.
Kwadwo, who has lived in Libya for less than a year, said the abuse was not unusual. "We are worse than dogs to the Libyans. If we were slaves, they would treat us better," he said on a recent day as he gathered up his jars, scattered in the muddy alley.
It was a brief sample of the tensions over one of Libyan leader Moammar Gaddafi's international experiments. During the 1990s, in the name of African unity, Gaddafi opened the borders to tens of thousands of sub-Saharan Africans to live and work in Libya. For the past four years, resentment over the policy has led to occasional riots and frequent bitter confrontations between the immigrants and Libyans.
In effect, the problems mark the end of an officially ordained dream.
Last month participants at an African Union meeting in Libya's coastal city of Sirte, Gaddafi's home town, rejected his proposal for a continent-wide army. A few days later, the General People's Congress, a consultative assembly that meets annually, ratified laws to restrict immigration and to expatriate Africans and other immigrants who live in Libya but have no steady jobs.
"You have work, you stay. You don't, you go home," said Giuma Abulkher, a government spokesman. "There will be strict controls."
The closed door is part of a shift in Libyan priorities. After decades of presenting himself first as a leader of the Arab world and then the African continent, Gaddafi has turned to the West. He is giving up chemical and nuclear weapons programs and declared that Libya would no longer support rebel movements across the globe. The United States is moving to restore diplomatic and trade relations cut off during decades of hostilities. Libya plans to privatize its state-dominated economy.
Shutting out other Africans will probably prove popular. In a closed, politically fearful society, opposition to Gaddafi's immigration policy is one of the few outward signs of discontent with his government. While Libyans are usually reluctant to openly discuss such issues as democracy, succession and economic policy, the immigration question provides a vent for complaints that quickly spill over into expressions of general unhappiness.
"It's about time. How can we have all these poor people here when we are poor ourselves?" said Osama Tayeb, a tout at a chaotic taxi stand in the old city. "First we help revolutionaries everywhere, then we give Libya to the Africans. Enough of this. Libya for the Libyans."
Mohammed Mabrouk, a waiter, blamed immigrants for a wide variety of societal problems -- crime, prostitution, dirty streets. "Look, they get away with everything. We could not touch our African brothers. They bring drugs, they smuggle people. We don't need this," he said.
Just over three years ago, resentment boiled over into violence. Libyans attacked African immigrants in several cities and killed as many as 130. Thousands of foreigners fled to their home countries carrying horrific tales of stabbings, shootings, beatings and robberies. Libyan officials, who said the violence was between African gangs, deported 6,000 Nigerians and 3,000 Ghanaians.
About 600,000 sub-Saharan Africans are estimated to live among Libya's population of 5.5 million. They were lured by a relatively stable currency and jobs that many Libyans, in their highly socialist economy, decline to do. They sweep streets, work in restaurants and peddle a dizzying collection of merchandise -- cosmetics, pirated recorded music, clothes and secondhand auto parts. Raggedy men selling single articles of clothing and knit caps stand in line inside an arched stone gateway to the old city.
Their headdresses and wool or cotton robes indicate origins across a wide swath of Africa: Nigeria, Ghana, Chad, Mali, Somalia, Sudan and Congo. Some of the migrants come to make the perilous journey to Europe across the Mediterranean Sea. Last summer, 200 Africans traveling to Italy by fishing boat drowned when their rickety craft capsized. During peak summer season last year, as many as 2,600 Africans arrived each month by boat on the Italian island of Lampedusa, an isolated stop between Libya and Sicily.
The influx prompted Italian officials to press Libya to stem the flow. The two countries agreed to exchange information to combat the migration, but Gaddafi balked at letting the Italians enter Libyan waters to intercept boats at sea.
Libya periodically announces roundups of migrants headed for Italy. Last week, Libya extradited an Eritrean woman known as Madame Gennet to Italy for allegedly smuggling 500 people into Italy last summer. Police also recently said they deported 200 Somalis who were preparing for a Mediterranean passage north.
African migrants speculate that the withdrawal of Libya's welcome will cause a spike in the number of people making the trip by boat next summer. "We are trapped. Life here is not going to get better, and no one wants to go back across the Sahara to his home," said Harbi Abdulahi, a Somali customer at the Barber Boss hair salon inside a little nook in the old city. "I think Africans may try to take any risk to get to Italy."
Badou Zaituni, a shoe repairman from Sudan, said he has lived in Libya for eight years and has grown fearful of his future. "A Libyan comes and asks me for money. I don't dare say no. The police will do nothing for us. We are surrounded by hate," he said.
Kwadwo, 19, said he would hang on and try to save money to get to Italy. He had come to Libya on the heels of his older brother, who works in a car repair shop. He traveled by bus across the vast Libyan desert, sometimes spending hours waiting under the hot sun as the driver made a series of repairs. "I almost fainted," he said. "I don't want to face that again, and there is little good work in Ghana."
Kwadwo said he thought it would cost him $1,000 to find a place on a boat heading north.
"Why not?" he said. "If I make it, I can send money home and help my family. If I don't, well, my life is not worth much as it is. I thought I could do something in Libya. If I can't do it here, I will have to try somewhere else. What do you know about Spain?"