It could have been a Saturday night in any Australian town. Against the backdrop of a fiery sunset, a line of vehicles snaked its way into the local drive-in.

At this outdoor theater, though, in place of advertisements for local businesses or a refreshment stand, something else was projected onto the giant screen: a reminder for patrons not to bring explosives into the complex.

Welcome to the South Australian town of Coober Pedy, the opal capital of the world, where in days gone by, Saturday night at the drive-in would often end with a bang.

“Coober Pedy has attracted its fair share of characters over the years,” said Stephen Staines, who works on the town’s district council. “People come here for the adventure, and miners would head to the drive-in with their utes” — pickup trucks — “packed full of equipment, including the gelignite they use out on the field.”

“If they didn’t like the movie or got bored,” he said, “it wasn’t unusual for them to throw sticks of gelignite at the screen.”

While nights at the drive-in are no longer quite as volatile, the locals are no less defiant. In fact, you need to be in order to survive in one of Australia’s harshest and most isolated environments.

Summer temperatures here average around 100 degrees Fahrenheit, and regularly top 110. Vegetation is sparse because of a lack of topsoil. Drought is an everyday reality.

So what attracts people to such a desolate and unforgiving place? In a word: opal.

Australia is home to a vast majority of the world’s commercial opal supply, much of which comes from the area around Coober Pedy. There are several hundred active mining claims, and prospectors working the claims estimate that a century of mining has left several hundred thousand mine shafts scattered around the region.

Miners begin by drilling deep vertical shafts before excavating outward in search of the precious opal veins. Machines called blowers are then used to suck the excavated rubble to the surface, creating enormous pyramidlike mounds that dot the landscape.

Like many others chasing the precious gemstone, Kenneth Helfand, a prospector, said it’s the possibilities offered by striking it big that have kept him mining opal for five decades.

“There’s opal on the field worth 10 or 20 thousand dollars an ounce — and when it’s cut and polished, it will fetch 10 times that,” said Mr. Helfand, an American who started mining opal in Coober Pedy in the early 1970s.

“What that buys you is freedom, and that’s what keeps you digging,” he said.

With a population of around 2,000 full-time residents, Coober Pedy is not on a lot of people’s radar. Roughly halfway between Adelaide and Alice Springs, and a day’s drive to each, the town is so isolated that the local football team’s away games are more than a 560-mile round trip.

My interest in Coober Pedy came via its connection with the British nuclear testing program of the 1950s and 1960s, conducted 200 miles away at Maralinga. Into the 1980s, anxieties lingered in Coober Pedy about the possibility that contaminated equipment — incliuding bulldozers and trucks — had been brought to the town from the testing sites. Even the town’s community hall was feared to be radioactive as a result of nuclear fallout. Now abandoned, it is an idiosyncratic relic from a disturbing period of Australian history.

As I first drove into town, though, it quickly became apparent that the hall and its nuclear legacy were not the only peculiarities that Coober Pedy had to offer. And so my fleeting visit became a weeklong stay.

Established around 1920 after the discovery of opal a few years earlier, Coober Pedy epitomizes life on the edge. Scattered around town are gopher-like earthen mounds, do-it-yourself mining operations, a dusty rock-strewn golf course, a cafe that serves homemade waffles and pancakes (while dabbling in the opal trade on the side), film locations and abandoned props and the societal debris accumulated across a century of isolation.

Nowhere is Coober Pedy’s weird and wonderful essence more evident than in the town’s unique solution to surviving the scorching summer heat.

Over half of Coober Pedy’s residents reside underground. And it’s not just the homes that are subterranean; the town also boasts underground stores, bars and restaurants, hotels and even churches.

While some structures utilize old mine diggings, many have been purposely carved into the surrounding hills. Maintaining a year-round temperature hovering around 75 degrees Fahrenheit, the dugouts, as they’re referred to locally, offer a prime escape from the heat of summer and the chill of winter. It’s one small constant in a town whose existence and success are tied to the fluctuating fortunes of opal mining.

“Take away the opals and you take away Coober Pedy’s heart,” Mr. Staines said. “It’s as simple as that.”

Back at the drive-in, halfway through the Saturday-night feature, Coober Pedy served up another surprise: A dust storm swept through town. With a resounding clap of thunder, cars were hit by the ensuing gale, blanketing them in red dust and interrupting the screening.

It was a timely reminder that, regardless of whether you’re above ground or below it, you never quite know what you’re apt to find in Coober Pedy.