In Zamashegu, a farming community of 1,000 people in northern Ghana, they may as well have come from outer space — four electric slot machines installed in two roadside shacks, chirping and clattering, bathing the packed-dirt walls in a pale, kaleidoscopic glow.

Their lure was magnetic. Soon, villagers stopped farming, leaving their yam and cassava fields fallow. Children stayed home from school. Instead, they’d queue up at the slots and play all day, until their pockets were empty or the village ran out of change altogether.

About twice a week, a Chinese man would arrive in a pickup truck. He would unlock the machines, hand some cash to the shacks’ owners and drive off — carrying about $100 in coins and, many villagers came to understand, their community’s hope for the future.

China’s influence across Africa has been deepening for decades — China surpassed the U.S. as the continent’s biggest trading partner in 2009 — and Ghana, a rapidly developing democracy of 26 million people on West Africa’s Atlantic coast, has been one of the relationship’s greatest beneficiaries.

Beijing has funded Ghanaian roads, dams, stadiums, hospitals and government buildings; it has flooded the country with inexpensive goods. Trade between the two nations hit $6.6 billion in 2016, up from less than $100 million in 2000. Ghanaian officials have welcomed the rise — in February, Finance Minister Kenneth Ofori-Atta called for an “enhanced relationship” with Beijing.

Yet Chinese entrepreneurs in Ghana are increasingly overstepping the once tightly prescribed limits of state control, and the widening presence of Chinese migrants selling cheap, low-quality goods at Ghanaian markets is undercutting — and infuriating — local sellers.

In 2013, the Ghanaian government arrested 168 Chinese nationals on suspicion of illegal gold mining, following reports of environmental devastation and social unrest.

Then came the gambling.

Chinese slot machines began appearing throughout rural Ghana early last year. And though the scope of the phenomenon remains unclear, interviews with dozens of villagers and officials in the country’s Northern Region — an area about the size of West Virginia, home to 2.5 million people — suggested that the machines have proliferated widely and precipitated an epidemic of gambling addiction that the government has been unable, or unwilling, to quell.

“For me what China is doing here is economic colonialism,” said Esther Armah, a prominent radio host and lecturer at Webster University in Accra. “Part of Ghana’s challenge is creating an economy that serves Ghanaians first and foremost. We don’t have that. We have an economy that first and foremost serves foreigners.”

Alexander Afenyo-Markin, a member of parliament for the Efutu Municipal District near Accra, about 300 miles south of the Northern Region, said local authorities have been lax on enforcement — and national officials, bound by Ghanaian law, are sometimes powerless to help.

“Most of these gambling centers have been opened without any authorization,” he said, adding that he knows of 15 in Efutu alone, run by several Chinese companies. “Now this has a lot of kids out of school, and it is also encouraging stealing and robbery.”

He has urged Efutu’s Municipal Assembly to muster a task force and crack down. “As a member of parliament I don’t have that capacity,” he said. “I can only do advocacy.”

The Northern Region is particularly vulnerable. About half its population lives below the poverty line. Many villages have no access to clean water. Child malnutrition is rampant. Yet the machines are everywhere, though mostly hidden from view: in a pharmacy; in an electronics store; tucked away in a dusty lot, flanked by small children.

Chief Ubor Dawuni Wumbe in his palace in Bunbong. (Noah Fowler / For The Times)

At first, Ubor Dawuni Wumbe didn’t even notice the machines.

Wumbe, the chief of Bunbong, a village of 2,500 people at the heart of the region, lives and governs — overseeing village projects, settling villagers’ disputes — in a brilliant white hut complex, insulated from the chaos of village life. But one day, “I noticed there was always a car that was parked here,” he said, gesturing to a dusty patch just outside the complex. Its driver was Ghanaian; its passenger looked Chinese.

In mid-2016, the Ghanaian government completed a major highway through the Northern Region, cutting travel time from Bunbong to Yendi District — a commercial center about 18 miles away — from several hours to about 30 minutes. “I think all of a sudden, [the Chinese] realized there was access,” Wumbe said. “That this was virgin territory, where they could ply on ignorance, or human emotion, to get rich quick.”

Soon he began seeing slot machines across the village; he counted 30, spread across 15 convenience stores, cafes and homes. They were strikingly crude: plywood boxes, each about the size of a mini refrigerator, sealed with a rusty padlock and outfitted with a coin slot, a metal tray and a flimsy plastic facade. They were emblazoned with famous figures — Super Mario, soccer player Lionel Messi — the faces sun-bleached and streaked with dirt. Minimum bets were 5 to 10 cents.

They were wildly popular. “You’d go there and it was packed,” he said. “People weren’t going to their farms anymore. People began to think that this was a way of earning income. They’d play all day, hoping they would win. But you never could beat the machine.”

Wumbe confronted the Chinese agents — by this point, he said, there were several — and demanded they remove the machines. The agents complied. Later, they returned offering a bribe of six soccer balls, imploring him to change his judgment. Wumbe refused. “We knew there were going to be a lot of problems in the near future,” he said. “You know it’s going to bring drugs, prostitution, robbery.”

But most villages seemed to be doing nothing. Across the region, the one-armed bandits were winning.

“I think there are a lot of people who feel the same way as I feel,” Wumbe said. “It’s just that nobody acts. We all just sit and talk about it. But nobody acts.”

Villagers bring two gambling machines out from a hut in Zamashegu, in Ghana's Northern Region. (Noah Fowler / For The Times)

Gambling in Ghana is legal and highly regulated; casinos line the streets in Accra, and online gambling, sports betting and lotteries are popular farther afield. Yet the primitive slot machines, and their link to underage gambling, have proved politically contentious.

In January 2016, officials in the Bolgatanga Municipal District, a two-hour drive from Bunbong, granted a Chinese company permits to distribute slot machines in local villages. Almost immediately, they were flooded with complaints: Children were skipping school to play, stealing from their parents. In June, they revoked the company’s permits, but the problem persisted. In September, they assembled a police-military task force and conducted a series of raids, confiscating 38 machines in total.

According to Bolgatanga’s municipal records, the machines belonged to a company called Pusheng Game Ghana Ltd., registered to a post office box in Accra. Yet officials in Bolgatanga could give no further details about Pusheng. The company has no website or public telephone number; its management could not be reached for comment.

“The headquarters is in Accra,” said Ayimbila Abubakar Ateer, Bolgatanga’s convener for justice and security. “If it’s in Accra, they are operating countrywide.”

In January, officials in Kyebi — a town in Ghana’s Eastern Region, about 430 miles from Bolgatanga — confiscated 40 Chinese-run slot machines, also because of underage gambling, local media reported.

In April, a Chinese slot machine owner “unleashed thugs” on a bar owner in Awutu Breku — a small town in Ghana’s Central Region — after accusing him of pocketing the machine’s take, according to the popular Ghanaian news website Adom Online. The bar owner, Isaac Akufu, reportedly landed in the hospital with knife wounds.

Yet not all local governments have reacted to the machines with ire. Yakubu Abubakari, presiding member of the Mion Municipal District assembly, also in the Northern Region, said he was wary about the machines’ social impact, but approved of their existence.

The machines’ Chinese owners saw him as a threat at first, Abubakari said, but warmed to him once they realized that he’d let them operate. He said one Chinese businessman, after a meeting with the assembly, handed him an envelope containing 150 Ghanaian cedis (about $30). He accepted the money.

The machines are “a form of business in the community,” he said. “So the person who is gambling with the machine [does so] at his discretion.

“Some win, and some lose, and that’s the game.”

Residents of the Northern Region frequently travel by bicycle and moped. (Noah Fowler / For The Times)

On a Saturday morning in Zamashegu, about a dozen villagers gathered around Azindo Nchegiri’s roadside shack — and his two Chinese slot machines — to share their grievances. The air was thick with dust and the sun blazed overhead, driving even the goats and chickens into the shade.

Nchegiri, a farmer, said he’s hosted the machines for about a year. Every three days, a Chinese man takes the earnings and gives him a cut — and every time, he loses it back to the machines. In total, he said, he has lost about $115, a hefty sum in the village. “I like playing,” he said. “But the money goes. That is painful.”

Wumbi Abubakr, 13, said the first time he saw the machines, about a year ago, he didn’t even know where to put the coins. An agent taught him how to play, and soon he was addicted.

“I was very happy then. I put in the money and won, and the sound that came out of the machine was very interesting,” he said. “I won 1.50 cedis [about 34 cents], then I played again and won 5. Then I continued until I went home with empty hands. That night I wasn’t happy.”

The other villagers saw no way to get rid of the machines; unlike in Bunbong, their chief has not lodged a protest. Villagers play obsessively, praying for a stroke of luck, and local hosts are disinclined to surrender a source of easy income.

“One time I told the [Chinese] man to take the machines and go, because I didn’t win,” said villager Jijiri Nchegiri, Azindo’s brother. “But he didn’t do anything.”

Suddenly, a child ran up to the crowd and shoutedthat “the Chinese” had arrived. The villagers hustled to the highway, where a white pickup truck sat idle. Its driver, a Ghanaian man, paced on the road, talking on a cellphone.

Moments later, a Chinese man emerged from a nearby shack. He was tall and pale, wearing a beige T-shirt and black baseball cap. He gave only his surname, Zhang. He said he’d been working as a cook in Hohhot, the capital of northern China’s Inner Mongolia region, when a Chinese agent approached him with an opportunity overseas. He had now beenin Ghana about a month and planned to stay a year.

“I'm really just here as a worker,” he said. “Because local people didn't know how to do this business, my boss brought me over.” As the crowd pressed in, he fell silent; his eyes darted uncomfortably. He said he was busy. He and the driver hopped into the truck and sped off down the road.

Half of the population in Ghana's Northern Region lives below the poverty line, yet the slot machines are almost everywhere. (Noah Fowler / For The Times)

This is the last in a series of reports on a massive program of Chinese investment that is reshaping Africa. Times staff writer Jonathan Kaiman and visual journalist Noah Fowler traveled to Ethiopia, Djibouti, Kenya and Ghana with support from the Pulitzer Center on Crisis Reporting. More online, including 360-degree videos, at latimes.com/chinainafrica