This story is excerpted and adapted from James Crawford’s book, Fallen Glory: The Lives and Deaths of History’s Greatest Buildings.

The most densely populated city on Earth had only one postman. His round was confined to an area barely a hundredth of a square mile in size. Yet within that space was a staggering number of addresses: 350 buildings, almost all between 10 and 14 stories high, occupied by 8,500 premises, 10,700 households, and more than 33,000 residents.

The city’s many tall, narrow tower blocks were packed tight against each other—so tight as to make the whole place seem like one massive structure: part architecture, part organism. There was little uniformity of shape, height, or building material. Cast-iron balconies lurched against brick annexes and concrete walls. Wiring and cables covered every surface: running vertically from ground level up to forests of rooftop television aerials, or stretching horizontally like innumerable rolls of dark twine that seemed almost to bind the buildings together. Entering the city meant leaving daylight behind. There were hundreds of alleyways, most just a few feet wide. Some routes cut below buildings, while other tunnels were formed by the accumulation of refuse tossed out of windows and onto wire netting strung between tower blocks. Thousands of metal and plastic water pipes ran along walls and ceilings, most of them leaking and corroded. As protection against the relentless drips that fell in the alleyways, a hat was standard issue for the city’s postman. Many residents chose to use umbrellas.

The postman of Kowloon Walled City in 1989. Greg Girard

There were only two elevators in the entire city. At the foot of some of the high-rises, communal and individual mailboxes were nailed to the walls. But often the only option for the postman was to climb. Even several stories up, the maze of pathways continued: knotted arteries that burrowed into the heart of the city along interconnecting bridges and stairwells.

Sometimes the postman would reach a top floor and climb out onto the roof. Gangways and rusting metal ladders let him move quickly from building to building, before he dropped back down into the darkness. While some alleys were empty and quiet, others overflowed with life. Hundreds of factories produced everything from fish balls to golf balls. Entire corridors were coated with the fine flour dust used for making noodles. Acrid, chemical smells filled the streets that lay alongside metal and plastic manufacturers. Unlicensed doctors and dentists clustered together, electric signs hanging over their premises to advertise their services. Many patients came from outside the city, happy to pay bargain fees in return for asking no questions. Shops and food stalls were strung along “Big Well” Street, “Bright” Street and “Dragon City” Road. For the adventurous, dog and snake meat were specialties of the city.

Moving deeper, long corridors offered glimpses into smoke-filled rooms. The incessant click of mahjong tiles echoed along the walls. Gambling parlors lined up alongside strip clubs and pornographic cinemas. Prostitutes—including children—solicited in the darkness, leading clients away to backroom brothels. And everywhere there were bodies lying in the gloom. At Kwong Ming Street—known as “Electric Station”—wooden stalls sold cheap drugs. Addicts crouched down to inhale heroin smoke through tubes held over heated tinfoil. Bare rooms, enticingly referred to as “divans” were filled with prone men and women, all sunk in opium stupors. Many of the city’s rats were addicts too, and could be seen writhing in torment in dark corners, desperate for a hit.

There was no law to speak of. This was an anarchist society, self-regulating and self-determining. It was a colony within a colony, a city within a city, a tiny block of territory at once contested and neglected. It was known as Kowloon Walled City. But locals called it something else. Hak Nam—the City of Darkness.

Kowloon Walled City’s Kwong Ming Street. Greg Girard

Following the first Opium War of 1839 to 1842—sparked, in essence, by the Chinese government’s attempts to prevent the East India Company from importing narcotics—China signed a treaty ceding a portion of its territory to Great Britain: a near-deserted, mountainous island with a sheltered, deep-water harbor at the entrance to the Canton River, opposite the Kowloon Peninsula. Hong Kong.

In 1843, the Chinese began to build a fort at the very tip of the Kowloon Peninsula, with an office for the Mandarin (the government official) and a barracks for 150 soldiers, surrounded by a wall that was 700 feet long and 400 feet wide. Known as Kowloon Walled City, it was intended as a visible Chinese military presence near the new British colony. In 1860, disputes over trade sparked a second Opium War. British and French forces devastated the Chinese, and a new treaty granted the whole of the Kowloon Peninsula to Britain, with a solitary exception—the Walled City.

Over the next 30 years, British authorities attempted to negotiate control of the city, but the Chinese remained firm. Even a new treaty in 1898, which granted Hong Kong, Kowloon, and further territories in Canton to Britain for 99 years, kept the Walled City under Chinese control. A year later, in May 1899, rumors circulated that Chinese soldiers were massing again in the Walled City, so the British sent troops across the water. They expected battle—perhaps another war—but found only the Mandarin. The irate official left too, and the British took the city, though the Chinese never renounced their claim. Missionaries moved in and built churches and schools, pig farmers from the surrounding hills took plots of land within the walls. There was almost no administrative control, and the city became a slum. Yet whenever the Hong Kong government tried to clear it to turn it into a park—evicting the residents in the process—the Chinese government always stepped in. After all, this tiny rectangle of land was still officially their territory.

The situation remained unresolved until the outbreak of World War II. Japanese forces occupied the Kowloon Peninsula and tore down the walls of the city to build a new runway for nearby Kai Tak Airport.

A temple within the Walled City, with grates above to protect it from refuse from upper floors. Greg Girard

In the aftermath of the war, refugees flooded south to the Kowloon Peninsula. The only trace of the old city was the derelict shell of the Mandarin’s house. Yet people gravitated almost instinctively to this rough rectangle of ground. Perhaps it was the feng shui. The Walled City had originally been laid out according to the ancient principles of Chinese philosophy: facing south and overlooking water, with hills and mountains to the north. This ideal alignment, it was said, brought harmony to all citizens. In their desperate plight some refugees may have believed that Kowloon would be a much-needed source of luck and prosperity. Others, however, recalled that this had once been a Chinese enclave in British colonial territory. The stone walls of the “Walled City” had gone, but the refugees were convinced the diplomatic ones remained.

By 1947 there were more than 2,000 squatters camped in Kowloon, their ramshackle huts arranged in almost the exact footprint of the original city. No one wanted to find themselves outside the borders—those on the wrong side of the line risked losing the protection of the Chinese government. The people kept coming, and the camp grew ever more squalid and overcrowded.

Appalled by the conditions, the Hong Kong authorities made plans to clear the refugees. On January 5, 1948, the Public Works Department, supported by a large police presence, removed the squatters and demolished all the slum housing. Within a week, however, the occupiers had returned to rebuild their shacks. When the police attempted to intervene, a riot broke out. News of the disturbances spread across China, and the plight of the “residents” of Kowloon became a cause célèbre. The British consulate in Canton was set on fire, and a group of students in Shanghai staged a protest strike. Officials from the Chinese government traveled to the Walled City—and officially encouraged the refugees to continue the struggle against their British oppressors.

The provincial Canton government sent a delegation on a “comfort mission” to the region, supplementing the distribution of food and medical aid with messages advocating militant action. The Chinese Foreign Ministry continued to argue that they retained jurisdiction over the city and its people. Amid mounting tension, the Hong Kong government relented. The eviction program was halted, and the police withdrew. From a temporary refugee camp, Kowloon now began to evolve into something more permanent. A new city was being founded on the ruins of the old.

Fish balls and other goods made in Walled City factories were exported to the rest of Hong Kong. Greg Girard

What kind of city? Naturally, the judgment of Sir Alexander Grantham, Governor of Hong Kong from 1947 to 1957, was damning. Kowloon, he wrote, had become “a cesspool of iniquity, with heroin divans, brothels and everything unsavoury.” The Chinese claims to sovereignty over Kowloon did not extend to any day-to-day administration; they merely used its uncertain status as a convenient tool for political point-scoring. After the disturbances in 1948, the Hong Kong government had settled on a similar policy of non-intervention. The result was a city outside the law: There was no tax, no regulation of businesses, no health or planning systems, no police presence. People could come to Kowloon, and, in official terms, disappear. It was little surprise that criminal activity flourished. Five Triad gangs—the King Yee, Sun Yee On, 14K, Wo Shing Wo, and Tai Ho Choi—took up residence. Kowloon’s extralegal status made it the perfect place for the manufacture, sale and use of drugs such as opium and heroin. The city that had been founded to police the traffic of opium became the epicenter of Hong Kong’s narcotics trade.

Organized crime may have dominated much of Kowloon, but it did not define the city. Entrepreneurs, attracted by low rents offered by private landlords, saw a unique opportunity. Hundreds of factories were established, with entire families manning the production lines. Conditions were often appalling, yet productivity—and profit—remarkable. Goods made in Kowloon were exported throughout Hong Kong, China, and even, in some cases, the world. Plastics and textile manufacturing were a specialty, as was food production. To the blissful ignorance of Hong Kong’s well-heeled residents, the dumplings and fish balls served in their restaurants were frequently sourced from Kowloon.

The citizens of the Walled City demonstrated an extraordinary capacity for change and adaptation. The boundaries of their world were tightly constrained, yet, as more people continued to enter the city, their architecture met the demand. As modern high-rises grew up in Hong Kong, the builders of Kowloon copied what they saw, erecting tower blocks of their own. Thin columns, established on foundations often consisting of thin layers of concrete poured into shallow trenches, started to extend skywards. With no requirement for planning permission, structures were thrown up with amazing speed. Subsidence and settlement were common. Because the high-rises would often lean against each other, residents called them “lovers’ buildings.”

This aerial photo shows Kowloon Walled City in 1989, while plans for its demolition were underway. Ian Lambot / CC BY-SA 4.0

As the blocks began to merge together, the city became less a collection of buildings and more a single structure, a solid block filled with thousands of individual units designed to meet every requirement of a city: living, working, learning, production, commerce, trade, and leisure. Increasingly, residents were physically sealed off from the outside world. Light did not penetrate down to the narrow lanes leading between the high-rises. It was the beginning of the City of Darkness.

A system of self-government gradually emerged. In 1963, for the first time in over a decade, the Hong Kong authorities attempted to intervene in Kowloon, issuing a demolition order for one corner of the city, and proposing to relocate the displaced residents to a new estate development nearby. When the plans were made public, the community instantly formed a “Kowloon City anti-demolition committee.”

At 9:20 am on January 14, 1987, 400 officials from the Hong Kong Housing Department erected cordons around the 83 streets and alleys leading into and out of the Walled City. Then they entered the city on a mission to contact and survey every single resident. Earlier that morning, it had been announced that the city was to be cleared and redeveloped as a public park—just as the Hong Kong Government had intended over half a century before. Except this time, there was to be no Chinese resistance. Two years earlier, on December 19, 1984, the governments of China and Great Britain had signed a joint declaration to transfer sovereignty of Hong Kong back to China on July 1, 1997. The Chinese Foreign Ministry had always used Kowloon as a political pawn to remind the British and the world of their claim over the land granted to Britain in 1898. The 99 years were almost up.

Kowloon Walled City in 1987, as seen from Tung Tau Tsuen Road. Greg Girard

The plans for clearance and demolition were kept secret. Compensation was a key element of the eviction process, so there was the danger of a sudden influx of people looking to take a slice of government money. For six months, the Housing Department kept Kowloon under surveillance to gather evidence of population numbers. The compensation package for residents and business owners totaled $2.76 billion. On average, residents received around $380,000 for their individual flats. Negotiations progressed over several years, and by November 1991, only 457 households were still to agree terms. By that time, most of the 33,000 residents had moved out. Some, however, clung on to the end, and on July 2, 1992, riot police entered the city and forced out the last remaining residents. A tall wire fence was erected to encircle the whole site—following almost exactly the line once marked out by the city’s original granite wall.

On March 23, 1993, a wrecker’s ball smashed into the side of an eight-story tower block on the edge of the Walled City. This was a solitary, ceremonial swing. The real work of demolishing Kowloon, piece by piece, would begin several weeks later. The moment was applauded by a crowd of invited guests and dignitaries. It was also greeted with shouts of anger from former residents who had gathered for one last, futile protest. It took almost exactly a year to reduce the rest of the city to dust and rubble.

Remarkably, from within the modern wreckage, fragments of the original city emerged. There were two granite plaques, each marked with Chinese characters: One read “South Gate,” and the other “Kowloon Walled City.” Once the ruins of the tower blocks had been cleared away, developers uncovered segments of the foundations of the original wall, along with three of the iron cannons that had once bristled from the city’s ramparts. A solitary building still stood at the center of Kowloon, the one structure to have survived throughout its whole turbulent history—the office of the Mandarin. Over the course of the next year, the ruins began their rapid conversion into a landscaped park, modeled on the famous 17th-century Jiangnan gardens built by the Qing Dynasty.

The roof was one place to find air and light in the “City of Darkness.” Greg Girard

The paths running through these new gardens were named after the streets and buildings of the demolished slum. The Kowloon Walled City Park was officially opened on December 22, 1995, by the British Governor of Hong Kong, Chris Patten. It had taken some six decades, but at last Kowloon was transformed into the “place of popular resort” envisaged by Sir William Peel, the Governor of Hong Kong in 1934: six-and-a half acres of ornate bamboo pavilions, pretty water features, and vibrant greenery.

This is the story of the rise and fall of a slum. It was born out of a quirk of history, it exploited its unsavory reputation, and, as is the fate of all slums, it became an embarrassment before being leveled by the authorities. Is there any greater significance to its story than that? Many would argue not. But while locals and tourists now enjoy the park, some still crave the claustrophobic darkness. Theorists from the wilder shores of architecture keep returning to the idea of Kowloon. On this tiny rectangle of ground, a single community created something that had only existed before in the avant garde imagination: the “organic megastructure.”

The concept of the megastructure emerged in the late 1960s, as a radical departure from the conventional idea of the city. Instead of buildings being arranged around public spaces, streets, and squares, the megastructuralists envisioned one continuous city binding citizens together in a set of modular units, capable of unlimited expansion. It was a city designed to live, evolve, and adapt, fulfilling all the needs of its people, and with the capacity to endlessly “plug in” more units to meet changing desires.

The beginning of the demolition of Kowloon Walled City, on March 23, 1993. ROBERT NG / South China Morning Post via Getty Images

Architects pushed this idea to extremes, most sensationally in the work of Alan Boutwell and Michael Mitchell, who in 1969 proposed a “continuous city for 1,000,000 human beings.” They envisaged a single, linear city, sitting on 100-meter-high pillars, running in a straight line between the Atlantic and Pacific coasts of North America. Kowloon, in effect, was proof of concept. Within its anarchist society, argued the megastructuralists, was the kernel of an architectural utopia.

Others, however, saw Kowloon not as a petri dish for urban theory, but as a model or diorama for a new kind of construction—one that did not exist in the ordinary physical plane, yet was as real as anything that could be seen or touched. The renowned American science fiction writer, William Gibson, described Kowloon, not long before its demolition, as a “hive of dream.” What Gibson saw in the unregulated, organic chaos of the City of Darkness was an embodiment of his famous concept of “cyberspace”—or, as we would call it today, the internet.

In its formative years, the internet provided the perfect environment for the establishment of multiple, self-regulating communities. Just like the Walled City, it operated outside of law or external oversight. It was post-design and post-government. Thousands, even millions of Kowloons could spring up at will in cyberspace: digital enclaves thriving on creative and political freedom, possessing an autonomous, dynamic structure that allowed them to grow at a frightening, near-exponential rate. It was also, just like the Walled City, living on borrowed time. “I’d always maintained that much of the anarchy and craziness of the early internet had a lot to do with the fact that governments just hadn’t realized it was there,” commented Gibson. “It was like this territory came into being, and there were no railroads, there were no lawmen, and people were doing whatever they wanted, but I always took it for granted that the railroads would come and there would be law west of Dodge.”

Kowloon Walled City Park was built on the footprint of the enclave. CHINA Landmarks and People by Vision / Alamy

Yet to Gibson’s mind, the people of Kowloon—and the megastructuralists—were groping toward the next stage in human evolution. He saw the Walled City, that accident of urban birth, as a crude, subconscious schematic of the future, a blueprint for coders and hackers, the architects of the web, to follow. In his 1996 novel Idoru, Gibson imagined a virtual Kowloon, a Walled City 2.0 recreated as an ultra-libertarian web sanctuary: “These people, the ones they say made a hole in the net, they found the data, the history of it. Maps, pictures … They built it again.”

So the wrecking ball may not only have been destroying a notorious slum. Perhaps Kowloon was also the first, true, physical monument to the internet. A city that offered a glimpse into the infinite horizons, structural possibilities—and inherent amorality—of the digital realm.

You can join the conversation about this and other stories in the Atlas Obscura Community Forums.