As he prepares to descend an abandoned mineshaft in the Johannesburg suburb of Roodepoort, Fix, a sinewy informal goldminer from Lesotho, recounts stories of subterranean gun battles and unearthing the scattered bones of those who came before him.

“This is very dangerous work,” he says, draining a quart of beer for courage. “But there’s a lot of money down there.”

[Rumours persist of] makeshift underground villages where basic foodstuffs, airtime, alcohol and even sex are sold

South Africa’s commercial capital of approximately 5 million inhabitants sits atop some of the world’s largest gold deposits, as evinced by the more than 200 towering spoil heaps that punctuate its sprawling cityscape. Millions of ounces of unmined gold are still believed to lie beneath its surface, fuelling a booming but frequently deadly illicit goldmining industry.

Fix, recruited and brought to South Africa by a criminal syndicate in 2013, has spent six years traversing Johannesburg’s estimated 140km (87-mile) labyrinth of underground mine tunnels. Sometimes, he says, he can go down a shaft in the far west of the city and emerge bleary eyed on its opposite edge a week later.

Q&A What is South African cities week? Show Hide Twenty-five years after the fall of the brutal apartheid regime, South Africa's cities remain hugely divided, both economically and racially. This week Guardian Cities explores the incredible changes taking place, the challenges faced and the projects that bring hope. Africa correspondent Jason Burke reports from the Flats, where violence and death are endemic just miles from Cape Town's spectacular beaches and trendy cafes. Author Niq Mhlongo pens a love letter to the "other Soweto", one that visitors to gentrified Vilakazi Street never see. We hear from Port Elizabeth, where one architect is using recycled materials to transform his city, and Durban, where a surf school is changing the lives of vulnerable children. We explore the deadly underground world of zama zama gold miners operating illegally under the city of Johannesburg, visit the Afrikaner-only town of Orania and publish an extraordinary photo essay by Magnum nominee Lindokuhle Sobekwa, who documents life in a formerly white-dominated area where his mother once worked as a domestic helper. Nick Van Mead

In some mining areas surrounding Johannesburg, informal miners have been rumoured to spend as long as six months underground, sustained by makeshift underground villages where basic foodstuffs, airtime, alcohol and even sex are sold at dramatically inflated prices.

Media reports suggest that more than 300 informal miners – most of them illegal, and known locally as zama zamas, meaning “take a chance” in isiZulu – have been killed by collapsing mineshafts or, more frequently, in turf wars between rival syndicates. Many more are likely still unaccounted for underground.

A man walks in front of a goldmine dump outside Soweto

According to a 2015 report by the South African Human Rights Commission, there are as many as 30,000 zama zamas operating across South Africa, most of them concentrated in and around Johannesburg. Like Fix, about 75% are said to be undocumented migrants, primarily from Lesotho, Mozambique and Zimbabwe.

The rise of the burgeoning illicit gold trade, which is estimated to cost South African coffers more than £753m a year, is largely a product of the formal mining industry’s collapse.

Gold was first discovered on the Witwatersrand reef in 1886, leading to the establishment and rapid industrialisation of Johannesburg and accounting for its longstanding status as the world’s largest city not found beside a major water source.

By the 1970s, South Africa was by far the biggest global gold producer, with more than 75% of all reserves, which contributed more than 21% of the country’s GDP. But a steep decline in gold prices and deposits as well as rising labour and electricity costs during the past decade led to widespread mine closures and almost halved the sector’s workforce by 2016.

'There is ingenuity in Africa': the architect who builds with trash Read more

“The significant level at which mines are still shutting down and retrenching has a direct impact on the number of people going to the informal mining industry,” says Kgothatso Nhlengethwa, a Johannesburg-based geologist and researcher on informal mining.

Today, there are an estimated 6,000 abandoned or disused mines across South Africa, the vast majority of them found along the so-called Golden Arc – the elliptical basin that spans the breadth of Johannesburg and continues into the neighbouring Free State and North West provinces.

Johannesburg, viewed from an old goldmine dump

Most of these sites have now been taken over by zama zamas and the violent syndicates that control them.

The recent political and economic turmoil of some of South Africa’s neighbours coupled with the inability of the ruling African National Congress to regulate the country’s informal mining sector has compounded the issue, pushing an increasing number of unskilled new arrivals into this perilous world.

Between 2011 and 2016, Gauteng province, which comprises Johannesburg, also added almost a million new inhabitants through net migration from other South African provinces. The country’s most urbanised province is expected to accept a million more internal migrants by 2021, the vast majority emanating from the still-underdeveloped former rural “homelands” created by the apartheid regime to segregate the non-white population from urban centres.

But with Johannesburg already experiencing a severe housing shortage and the national unemployment rate sitting at 29%, many of the new migrants, both local and international, are pushed into the growing expanse of outlying informal settlements, where opportunities for formal employment are particularly scant.

Poor migrants, many of them from Zimbabwe, have moved into dilapidated bungalows in Durban Deep’s old mining village. Photographs: Shaun Swingler

In Durban Deep, a defunct Victorian-era goldmine on the western flank of Johannesburg, hundreds of poor migrants, mostly from Zimbabwe, have moved into the crumbling bungalows of former white mine employees.

The once leafy and affluent mine village, and its recently shuttered golf course, are increasingly enveloped by two warren-like informal settlements. Together, they account for about 40,000 inhabitants and epidemic levels of violent crime often associated with mining syndicates.

“Maybe 85% of people in this area are making a living from illegal mining,” says Fani, a middleman who resides in a dilapidated Durban Deep home and sells locally mined gold to pawnbrokers and jewellers from across the city, who will then launder it into the legal market for eventual export.

According to David van Wyk, a mining researcher at the Johannesburg-based Bench Marks Foundation, there is a dependency ratio of about eight to 10 people per illegal miner. “So that’s about 400,000 people who are dependent on small scale mining,” he says.

Kassim Bhorat: ‘When the mine closed in 1999, business went down considerably.’ . Photograph: Shaun Swingler

This figure excludes local businesses in areas that have often experienced significant economic downturn and visible urban decay in the wake of formal mine closures. Many such businesses are now heavily reliant on zama zamas for trade.

Kassim Bhorat’s grandfather bought a small convenience store near Durban Deep in 1958, when the mine was in its heyday, which Bhorat then took over and rebranded as an electronics outlet in 1990.

“When the mine closed in 1999, business went down considerably,” he says. “But then about 10 years ago the zama zamas started moving in and that helped a lot. I imagine many other businesses around here would say the same.”

A group of zama zamas from Zimbabwe work behind the informal settlement of Matholesville. . Photograph: Shaun Swingler

In the nearby settlement of Matholesville, scores of vendors sit on crowded street corners selling headlamps, balaclavas, knee pads and other essentials to a clientele almost unanimously looking to carve out its existence underground.

“You have entire subsidiary industries developing around sites where illegal mining occurs,” Robert Thornton, a Wits University anthropologist who specialises in illegal mining, told local media in 2017.

Numerous zama zamas, activists and researchers claim that local police also profit from this underground economy by taking bribes and kickbacks from buyers and syndicates, or by confiscating gold from the zama zamas only to sell it themselves. “The cops just want money,” says Fani. “They don’t care about law enforcement.”

The town of Carletonville outside of Johannesburg has been hit hard by the collapse of formal mining. Photographs: Shaun Swingler

A short drive beyond the city limits, the town of Carletonville and many of the former mining villages that surround it, until recently the bedrock of Gauteng’s formal mining sector, have fallen into a similar state of abandonment.

A number of run-down properties and scruffy sections of road around the town have been partially swallowed by sinkholes, which locals say often appear after bouts of tremors resulting from activity at the diminished number of still-functional local mines.

Thabo Dikgang, a zama zama from Carletonville, processes gold outside his home. Photographs: Shaun Swingler

Combined with the hulking unrehabilitated mine dumps that enfold Carletonville and kick up great clouds of toxic dust when the wind blows, the area has a decidedly dystopian feel and provides a stark depiction of the death rattle of the formal mining industry.

In 2017 alone, as many as 8,500 people were retrenched from formal mines in Carletonville, with most of those who could afford to do so joining the growing exodus into Johannesburg.

Rethabile Mokwena is a broker between local zama zamas and a wealthy buyer from the city. Photograph: Shaun Swingler

Rethabile Mokwena used to work as a local contractor for Sibanye-Stillwater, the largest individual producer of gold from South Africa. He now makes a meagre living as a broker between local zama zamas and a wealthy Zimbabwean buyer from the city.

He undertakes the laborious and hazardous process of refining gold dust into amalgam with a blowtorch and mercury in a small corrugated zinc shack, or “burn house”, behind his one-bedroom home in a sand-swept township on the edge of Carletonville.

Mokwena says he has problems with his lungs as a result of the work. According to Nhlengethwa, the gold is usually extracted from silica-based rock, which can cause silicosis, a chronic lung disease that has claimed the lives of thousands of mine workers since the 1960s.

“The large-scale mining companies have a way to mitigate that risk by providing proper protective gear to avoid inhaling those particles,” she says. “The zama zamas do not.”

Aside from the health risks, Mokwena says that police regularly raid his house and confiscate any gold and cash they find. “But they won’t arrest you,” he adds. “They’ll just sell your stuff to other buyers.”

“There is no other work,” says Thabo Dikgang, a burly local zama zama whose earnings support a wife and five children. “Even if someone dies inside those shafts today, someone else will be there to take his place tomorrow.”

Follow Guardian Cities on Twitter, Facebook and Instagram to join the discussion, catch up on our best stories or sign up for our weekly newsletter. Share your views here on how South African cities have changed in the last 25 years