DAKAR, Senegal -- The lucky ones have hidden out on cocoa farms and in Chinese-owned companies, surviving on yams and water, moving about constantly and trembling at the prospect of being discovered by Ghana's security forces. The unlucky ones have been beaten, robbed and swept up by soldiers.
A dream of wealth in a far-off land has been turned on its head for hundreds of Chinese gold miners in Ghana. At least 169 of them were rounded up by the government this month, accused of sneaking into the country and overstaying visas to illegally mine one of Africa's richest gold fields.
"We have no food, no water, no sleep," a Chinese migrant said as she hid from the government on a cocoa farm late last week, adding that more than 100 others were there too, fearing arrest. Now the group has fled again, she said, hoping to make it safely back home. "Everyone is scrambling for a way to go back to China."
The mass roundups have injected a bitter twist into a relationship that is vital for Ghana, which counts China as one of its most important economic partners. Ghana has oil and other coveted minerals, and the Chinese are busy there erecting government ministry buildings, a giant dam and even a stadium.
But much further down the economic scale, Chinese workers -- plumbers, electricians, small shopkeepers -- have also made their way to a West African success story to dig up the land, many of them fleeing poverty at home.
The polluted holes that now dot the Ghanaian countryside from these small-scale mines have proved too much for the government, which agreed over the weekend to release the migrants it was holding as long as they left the country. More than 200 others have given themselves up voluntarily, and the pressure continues, with an anti-illegal mining task force "still in operation," said Michael Amoako-Atta, a spokesman for the Ghana immigration service.
Spurred on by popular resentment toward the Chinese miners, the Ghanaian authorities have raided camps, mines and hotels, wherever the migrants gather. Their methods, the Chinese migrants say, have not been gentle.
"The soldiers broke my windows and came into my room," said a miner's wife, recounting a nighttime raid on June 2 at a hotel in the gold-mining town of Dunkwa. "They just yelled 'Go! go! go!' and 'Fast! fast! fast!' at me," said the woman, who gave only her last name, Huang. "They even hit me."
The soldiers were not simply seeking to make arrests, she said. "They didn't ask whether we were gold miners," she said. "They just took all the cash away first. If they found any car key, they would also ask you which car is yours and they would drive the car away."
She said she was taken to a local jail but managed to buy her way out. Others were sent to a detention center in Accra, the capital, but she said she was determined to stay in the country "because I'm a businesswoman."
The roundups have stoked fear among the Chinese migrants and anger at home, generating more than one million posts about the topic on one popular microblog. Chinese officials said they had dispatched personnel to mine sites to investigate, while the authorities in Guangxi, the Chinese region that many of the miners call home, have urged residents not to go to Ghana. The Chinese Embassy has agreed to pay bail, fines for breaking the immigration law and passage home for scores of the miners.
"We went to hide in cocoa farms for three days," said Shi Jian, a 34-year-old miner from Guangxi Province in southern China. "There was no food, so we ate yams only."
"When the military police came, they first took whatever valuables they could take -- gold, cash," Mr. Shi said. "Then they poured out the diesel we keep on the site to power the generators and burned all of our excavators and camps."
A long furtive walk in the bush preceded a nighttime dash to a Chinese-owned company in Obuasi that sheltered him from the authorities. "We scurried to this company at night like rats crossing streets."
Others described a huddling together in a large group, hoping to evade detection.
"There is no rest," the woman who hid on a cocoa farm said late last week. Fearing reprisals, she gave only her last name, Li, and took deep breaths as she described her predicament. "We have to move on to a new spot in the cocoa farm every hour because we don't want the villagers to see us."
Now, she says, the group no longer hopes to stay in Ghana, having abandoned the cocoa farm on Friday night to make its way to the capital -- and eventually back to China.
"We don't ask for anything now," she said. "Just let us go back to China safely."
Some had only recently begun mining operations. With the raids, they have lost everything, they said.
"I've been working on my site for only two months and then came this raid. I haven't even produced any gold, so now I don't have anything left," said Pan Huarong, who had been in hiding since May 20, when word of an impending raid came down. Like others, he barely had time to gather up a few clothes before fleeing.
Analysts in Ghana said the government had little choice but to act against the illegal miners. Mineral concessions, in theory, are controlled by the government, and many accuse the Chinese of using Ghanaians as fronts to engage in small-scale mining from which foreigners are otherwise barred.
"It comes in the context of growing public agitation over the destructive, quite predatory, medium-scale mining operations engaged in mainly by the Chinese and some Indians," said Emmanuel Gyimah-Boadi, executive director of the Center for Democratic Development in Accra. "The public has been quite agitated, and has put a lot of pressure on the government to act."
The migrants suggested that the local authorities had tolerated their presence, at a price.
"Every day my heart was trembling," said Lan Qihua, an electrician from Guangxi who came to Ghana in September. "Police, military, they came every other day. Sometimes our Ghanaian partners came, too, seven or eight people together, brandishing machetes and asking for money. A lot of the time I was just totally exhausted, like there wasn't enough oxygen in the air."
The migrants are critical of the Chinese authorities in Ghana for not doing more to protect them. "We called the embassy," Mr. Shi said. "They told us, 'You are all illegal; how dare you to call us now?' "
Now, the only aspiration of many is to leave the country. Luo Mingjun, 35, said that he formerly worked in a factory in Yiwu, in Zhejiang Province, but that his boss owned a gold mine in Ghana and sent him to work there late last year. He and 10 other Chinese miners escaped from the mining site during the night, he said, unable to retrieve the belongings they had left behind in their rented room in Dunkwa.
"I feel very insecure because of the violent way Ghana has enforced its law," he said, "so I want to go back to China very much."
Adam Nossiter reported from Dakar, and Yiting Sun from Accra, Ghana. Chris Stein contributed reporting from Accra.
Correction: June 11, 2013, Tuesday
This article has been revised to reflect the following correction: An earlier version of the map with this article mislabeled what should have been the country of Guinea as Senegal..
This article originally appeared in The New York Times.