Lagos’s dysfunction extends out to sea. Oil tankers and container ships clutter the horizon beyond Lighthouse Beach, idling in anticipation of a docking slot at the only large-scale commercial port in Nigeria, a country of 180 million people. The Apapa Port perches at the end of a thin peninsula and is accessed through a badly degraded roadway that can sometimes back up for days. The beach itself is breezy and barren, despite being less than ten minutes by boat from the cram-packed Lagos Island downtown. Shipwrecks litter the shore—there’s a barge cinematically plowed into a jetty, along with the metallic outlines of several boats that ran aground years ago and have since been harvested down to the keel. Lookouts in a scrap-metal hut keep watch over a nearby freighter that had tipped over in the shallows about three weeks earlier. Whether they’re the doomed vessel’s owners or enterprising salvagers isn’t clear; these kinds of ambiguities are common in Lagos. One Lagosian tells me that, after his apartment was robbed, a police detective cheerily assured him that they knew who the culprit was—a statement somewhere between a boast and a solicitation for a bribe. “The cops know the criminals,” he explains. “They live together, they hang out, they share information.” In Lagos, he continues, “nothing is guaranteed. Everything is relative. Your yellow cab could be driven by a drug dealer, or it could be driven by a banker who wants another income. You just don’t know.”

Poverty, confusion, and moral fluidity haven’t stopped Lagos from achieving global prominence. Maybe an all-pervading looseness has even been a source of the city’s growth, since it has expanded with a velocity that prudent planning would avoid. Lagos is now West Africa’s economic and cultural hub, as well as perhaps the continent’s largest city, depending on which population figures one accepts. By most accounts, Lagos has twice as many people as London, along with a GDP greater than all but six African states. In its successes and failures, the city offers a cautionary preview of where an urbanizing developing world is hurtling.

Even Lighthouse Beach, miraculously tranquil and isolated, by Lagos standards, reveals how strained the social and physical environment can quickly become in a city that’s growing out of control. The only buildings visible from the shoreline are two empty high-rises on the other side of the narrow channel connecting Lagos Lagoon to the Atlantic. The mirage-like structures, one resembling a forest of metallic cylinders, are the largest completed buildings in Eko Atlantic, a 6.2-square-mile landfill project being added to the southwestern end of Lagos’s Victoria Island section. The towers stand alone in a barren gravel plain, but the new development will eventually host corporate offices, beach resorts, and housing for as many as 400,000 people.

The project seeks to expand the congested Victoria Island area, while creating a glittering showcase of world-class high-end real estate, thus helping to reverse Lagos’s reputation for disorder. But the initiative reflects a certain myopia: the landfill destroyed Bar Beach, once a popular public space in a city with no large parks and few major squares or monumental avenues. It’s not obvious whether the existing infrastructure can support such a large development so far off the mainland; as it is, Victoria and Lagos Islands are accessible only through a gauntlet of traffic choke points. The development is also aimed at a tiny upper sliver of an overwhelmingly poor city. “The plan is to create a Dubai and just ignore people who can’t afford to live in the proverbial Dubai, which describes most of the population,” says Olaolu Ogunmodede, a researcher at the Lagos-based Center for Public Policy Alternatives and an editor at The Republic, of the Lagos state government’s approach. (The city is organized as a state within the Nigerian federal system.)

Along the churning shallows in Lighthouse Beach, a team of fishermen hauled in a line of net about 50 feet long, stretched between splintering wooden stakes. Tarkwa Bay, about a quarter-mile down the beach, is a village within a vast metropolis, with huts and shacks shaded under high palm trees. No paved roads connect the area to the downtown less than two miles away—it’s off the grid, even by Lagos standards. But between weekend beachgoers, fishing, and salvage, the community has a lively self-contained economy, and residents have little reason to venture too far.

In nearby Ikoyi and Victoria Island, affluent Lagosians have little reason to venture too far, either—they live in gated estates, with their own security, garbage collection, electricity, and private bus services. One gets frequent reminders of how segmented Lagos is, how cordoned off its parts are from one another. Cut down a side street in Ikeja, and you’re suddenly in a squalid parallel world, where generators scream beside narrow mud streets, lined with freelancing numbers-runners and peddlers hawking broken clocks. The alley ends, and the modern downtown resumes again. From the Third Mainland Bridge, travelers can see the plush villas of Banana Island and Lekki glimmer in the distance at night, while the vast lagoon-side Makoko slum, less than 500 yards west of the six-mile-long causeway and home to an estimated 250,000 people, is invisible in the darkness. Makoko has become a transit point for timber from farther down the coast, creating yet another vibrant hyper-local poverty economy. You can smell the tang of burning garbage and wood from the bridge whenever traffic slows.

Cheta Nwanze, a researcher at SBM intelligence, offers more insight into the city’s divisions. Nwanze and another SBM analyst, Ikemesit Effiong, meet me at Seven Eagles Spur, a diner-style restaurant inside Ikeja’s City Mall, decorated in images of southwestern American desert highways and chiefs in feather headdresses. Nwanze informs me that, a decade ago, the land that the mall now occupies was a slum. Residents were removed with a minimum of due process or public deliberation—still the standard procedure for any big-ticket Lagos development project. The mall has a KFC and a Nike store, and our lunch bill comes out to 9,100 naira, or $25. The people who had lived on the site of the future mall probably never imagined such a thing. “You give someone 9,100 naira and tell them to kill someone, and they will do it,” Nwanze says, only half-joking.

Lagos is booming. Credible estimates put the population at 17 million or 18 million, but the city defies understanding of its true scope. “Most Nigerians can’t be accessed even by the government,” Effiong notes. This relative lack of data could turn out to have broader significance, since the world is sure to look more like Lagos in the coming decades. An estimated 54.5 percent of the global population now lives in cities, but urbanization is less complete in the developing world. Slightly more than half of Asia’s population, and nearly 60 percent of Africa’s, still lives in rural areas. The number of cities with 500,000 inhabitants or more is expected to grow by 80 percent in Africa alone between now and 2030, and the ten cities that the UN projects to cross the 10 million–inhabitant “megacity” threshold by 2030 are all in developing countries. By 2030, some 730 million people, or 8.9 percent of the people on earth, will live in these megacities, up from the current total of 500 million, or 6.8 percent. Success has made Lagos an unnerving glimpse into the near future.

Like other cities of its size, Lagos has multiple centers of gravity. The main business district is in Lagos Island, with its dauntingly crowded streets, rotting colonial-era buildings, and boxy skyscrapers dating back to the 1980s oil boom. Multinationals set up shop in calmer, upscale Victoria Island; traders flock to frenetic wholesale markets in Ikeja; and the region’s most important tech ecosystem has sprouted in the once-rundown mainland neighborhood of Yaba. The city is an exporter of culture, whether through “Nollywood” (Nigerian) films, fashion, or the globally influential Afrobeats sound. “Lagos gives you a broad canvas,” film director Tunde Kelani says. “It just depends on what you are looking for. Lagos is the whole of the country.”

The city both epitomizes and contrasts with Nigeria. Since colonial times, Lagos has never fully belonged to any of Nigeria’s religious or ethnic groups. In 1867, refugees from conflicts in the Abeokutta region settled in what became the Ebutte-Metta neighborhood, in the modern-day city’s mainland, and former Brazilian slaves flocked to Lagos Island in the mid-1800s, accounting for more than 10 percent of the city’s population and forming the core of its merchant and professional class. There are less savory reasons for Lagos’s centrality. Nearby Badagry was one of West Africa’s busiest slave ports, and Lagos was both the center of British colonial administration and the postindependence capital during a series of military-led governments (the capital moved to Abuja in 1991). “Nigerian government is hopelessly centralized, so all the federal projects centered on Lagos for 60 years,” says Nwanze. The city’s monuments of centralization are decaying—Tafawa Belewa Square, once a stadium and public parade ground during Nigeria’s military administrations, is now an eerie, squatter-filled modern ruin, its crumbling towers and grandstands looming over the Lagos Island downtown.

A more liberal vision of centrality has prevailed in the city, however. Lagos is now the region’s focal point of wealth and ambition to a degree that would have been impossible during earlier eras, when Nigeria was a dictatorship and people, capital, and ideas migrated slowly. “Almost anyone can find their people in Lagos,” says Yele Bademos, founder of Micro Traction, an online platform aimed at facilitating investment in Nigerian start-ups. “Anyone trying to do anything interesting is here, rather than anywhere else.” Bademos describes the city, where he moved in 2015, as a “rising tide,” and marvels at the maturation of its tech ecosystem over just the previous 18 months. Things change quickly, for better and worse. Beaches, roads, buildings, and entire neighborhoods appear and disappear without clear explanation. Even something as seemingly trivial as the ride-sharing market, a service unaffordable for most Lagosians, suggests how the city lurches between possibilities: Uber had conquered Lagos, until drivers defected en masse to Taxify, an Estonia-based Uber clone, in mid-2017.

This constant flux can make for a verdant creative environment. Jumia and iRoko, West Africa’s leading e-commerce and entertainment streaming services, respectively, are regionally important companies founded in Lagos during the past decade. Music and movies produced in the city dominate West Africa and beyond—it was a Lagosian, Wizkid, who appeared alongside the Canadian pop star Drake in his 2016 megahit “One Dance.” As Edet Okun, an assistant curator at Lagos’s Nimbus gallery explains, the city has also fueled a burgeoning art market. “The money is here, and you have a high concentration of people,” Okun says, guiding me through a collection that includes traditional Ife bronzes, as well as striking monochromatic abstract works from Nigerian artist Olu Okekeanye.

Attracting Nigerians of every description, Lagos offers hope for a country often defined by its religious, regional, and ethnic cleavages. It is the exception to Nigeria’s fault lines, “probably the one place in the country where, regardless of where you came from, you can feel like you belong,” one Nigerian told me. For some Lagosians, the rationalized marketplace of the city is also the only way of escaping a dead-end village economy, in which labor is a social or familial obligation, rather than a source of money and freedom. “A lot of these many odd jobs that people do for free in rural areas, people pay for in Lagos,” says Ray Ekpu, cofounder of the magazine Newswatch. Ekpu moved to Lagos from Nigeria’s southeast in 1980 and has seen the worst of the city: he was imprisoned six times during military rule, and a close colleague at Newswatch died in a mail-bomb attack in 1986 that many suspected was linked with the magazine’s work. “People come searching for the bright lights,” Ekpu observes. “They think they can find a good life here. Some of it is true. Some of it is a myth. They think if they can get here, they can find something to do.”

That Lagosian myth—of opportunity and an escape from Nigeria’s various social and political ills—has an intense hold over the country. “The way people migrate or immigrate to the U.S., that’s how people move to Lagos from other parts of Nigeria,” says Idayat Hassan, director of the Abuja-based Center for Development and Democracy.

The myth is especially compelling against the backdrop of the crisis in Nigeria’s northeast, where the jihadist Boko Haram insurgency has killed as many as 15,000 people since 2009, displacing nearly 2 million and setting the stage for an ongoing famine. The group’s initial grievances were based on the status of Islamic law in Nigeria’s majority-Muslim north. Nigeria’s geographic cleavages could mean that the group’s murderous ambitions won’t extend to coastal, cosmopolitan Lagos: the group has claimed only one attack in the city, a bombing at a fuel depot that killed two people in 2014. Lagos has thrived during an emergency that has likely deepened Nigeria’s regional differences but done little to undermine the city’s inherent strengths.

“Lagos has been a hustler’s paradise,” Kola Tubosun, a linguist and programmer tells me at a Google-organized conference at the recently opened Landmark Center, near the Lekki coastline. During a talk a few minutes earlier, Google CEO Sundar Pichai had spoken as if Lagos were a guide to what the future would look like. “We have to come to places like this to see how things will evolve over the next ten to 20 years,” Pichai said. Pichai intended to highlight how Lagosians had thrived in a low-bandwidth and low-infrastructure environment, partly by building apps and other tech-driven services that respond to their difficult situation. One company, called WeCycling, proposes to take care of recycling, in the absence of reliable collection; another, called Emro, is tantamount to a subscription-based 911 service and exists for the same reason.

Infrastructural lapses aside, Lagos uneasily embodies one of civilization’s fundamental divides: the split between the city and the provinces, between a flagging periphery and the center toward which that periphery gravitates. The numbers reflect an astounding imbalance. Lagos contributes more to Nigeria’s GDP than any other state, and twice as much as the second highest-ranked state. Only 214 Nigerians pay 20 million naira ($56,000) or more in taxes each year; all live in Lagos, which collects some 39 percent of Nigeria’s internally generated revenue. Lagos state governor Akinwunmi Ambode has claimed that 60 percent of the country’s industrial and commercial business takes place in his city.

Lagos’s growth is partly a function of a national-level failure to create opportunities or develop critical infrastructure elsewhere in Nigeria. “Coming to Lagos is sometimes the only alternative people have,” says Kelechi Anabaraonye, a historical-preservation activist and scholar of Lagos’s history. Some 2,000 people move to the city daily, and they arrive in a place that’s alarmingly unprepared for them.

“Lagos was built to be Copenhagen but ended up like New York,” says Saratu Abiola, an Abuja-based writer. “It’s already a lady wearing a dress five sizes too small.” Indeed, the city has expanded despite a deficit of meaningful urban planning and the structural dysfunction imposed by Nigeria’s federal system. Lagos doesn’t have a municipal government: it is subdivided into 20 local government areas, or LGAs. Lagos Island constitutes an entire LGA, for instance. The State Assembly is headquartered in the leafy mainland neighborhood of Ikeja, and Lagos state’s boundaries include places like Badagry, which is part of the metro area but functionally a separate city (and also its own LGA). Nigeria’s 1999 constitution, written under military rule in preparation for a shift to civilian control, reserves more than 60 responsibilities exclusively to the federal government, including such mainstays of local governance as policing, state government borrowing, and the issuing of driver’s licenses.

Disputes between Lagos state and the federal government in Abuja are common. For instance, in 2004, then-president Olusegun Obasanjo cut off federal funding for Lagos’s LGAs during a dispute with Lagos governor Babatunde Fashola. Abuja controls a number of crucial infrastructural assets in Lagos but has failed to maintain them; the Apapa Port Road is a notable example. During Fashola’s administration, the state government would post notices near especially degraded federal highways, aimed both at Lagosians and the government back in the capital: THIS IS A FEDERAL GOVERNMENT ROAD. PLEASE BEAR WITH US. LAGOS STATE GOVERNMENT. This local-federal tension may never be resolved. In a country so divided, reopening discussion of even a plainly imperfect constitutional arrangement can have unknowable consequences.

For now, state, city, and country muddle along. While Ambode is generally thought to be no worse than his recent predecessors, the city’s few stabs at reform have tended toward half-measures or overreach. Slum clearances are common. There’s discussion of building new power plants, but only 40 percent of Lagosians can access the city’s electrical grid; 80 percent of households rely on diesel generators. The government wants to phase out danfos, the ubiquitous and often beat-up privately operated minibuses that swarm Lagos’s highways, but that would shut down the city’s primary mode of public transportation, while strengthening the position of politically connected bus operators. The government has already banned the hawking of goods in the middle of roads and highways, though it enforces the law arbitrarily and ignores the reasons that hawking is so prevalent, including the shortage of affordable commercial space and the market opportunities that the city’s chronic traffic problems create.

Nearly every positive development in Lagos has happened without much state or federal involvement. “Nollywood is an example of Nigerians spontaneously organizing a marketplace to expand goods and services independent of the government,” notes Effiong, describing the city’s flourishing film industry. He cites Computer Village, Lagos’s rambunctious electronics market and site of some $2 billion worth of commerce each year, as another example. Yet, in May 2017, the state government announced plans to relocate Computer Village to a newly built technology park on the city’s outskirts, throwing the market’s survival into doubt.

This type of meddling misreads the city’s strengths and barely addresses its actual needs, which are likely to get increasingly severe. Lagos is already an agglomeration of slow-motion catastrophes that no one seems willing or able to solve, beginning with the likelihood that the population will double by 2050. “The rate at which Lagos is going, we’re going to find out the places where we didn’t do enough,” Anabaraonye says.

Drainage is one such area; transit is another. Trench-like open sewers are common even in expensive neighborhoods. “Lagos is a model until it rains,” a presidential advisor in Abuja says. Lagos has no metro or commuter rail, though a single light rail line is six years behind schedule. It has few ferries, despite being organized around islands, creeks, and lagoons. Lagosians know that some road journeys are inadvisable, or even impossible, at certain times of day: generally speaking, one should try to avoid heading from the mainland to the islands between 7 AM and 10 AM.

Major roadways are existential clashes of galloping danfos, weaving two-wheelers, street hawkers bounding between tight rows of traffic, and the occasional traffic cop pleading for order. The hawkers seem to materialize out of nowhere as soon as traffic slows, no matter the length of the delay or the time of day. They’ll make their sales when the traffic stops, and then run alongside their customers to count out change once progress resumes. They frequently sell bottles of water, phone chargers, or packets of coconut chips, but they’ll peddle anything that they can acquire and carry. I saw people selling neon construction vests, sandals, Richard Branson books, Christian literature, paintings, and even a globe.

The road is virtually the only true public commons in Lagos. The highways fill the same psychic space that parks or beaches would in other cities: they’re where everyone meets. In Lagos, the city’s primary shared precinct is a market and a battlefield, rather than a park or a seashore. “When you get to a traffic circle, it’s like Armageddon,” says Ogunmodede of The Republic. “Lagos is survival of the fittest. . . . If you don’t get ahead, someone will get ahead of you.” Barely roadworthy cars cut between lanes like running backs bounding down a football field. Actual games of chicken take place, with drivers hurtling at one another until the last possible second. The roadways are an expression of the desperate energies that shape life in Lagos. “The mean Nigerian is just somebody who wants to survive, especially here in Lagos,” maintains Ogunmodede. He describes his city as “a competitive, dualist world.”

Survival extracts barely tolerable costs that have nevertheless been internalized as normal. A general lack of trust means that an apartment rental often requires a year of rent up-front. Some 60 percent of Lagosians live in informal or unregistered structures—it’s common for danfo conductors, many of whom are young unaccompanied migrants from elsewhere in Nigeria, to live in their vehicles. At night, traffic lights become gatherings of the legless, armless, and lame. Much of life is spent battling other people—for business, breathing space, and painfully elusive intervals of quiet.

Lagos is Nigeria’s engine of growth, the beginning of its supply chains, the source of its soft power, and a driver of the country’s broader aspirations and hopes—“a large lab where you can experiment, pretty much freely,” as one immigrant from a neighboring West African country puts it. The warning that Lagos offers is how little that seems to correlate with quality of life. The city faces the unsettling question of what kind of social compact can emerge in the absence of a plausible means of advancing the common good. That question will begin to haunt other places, too: Lagos won’t be the only megacity to test how much infrastructural and institutional decay a place can withstand before it reaches a breaking point. Meantime, the city seems as if it will continue on its present course, fraying and fracturing, even as it expands.

Top Photo: “It’s like Armageddon,” says one resident of Lagos traffic. The city’s population, estimated between 17 million and 18 million, could double by 2050. (George Osodi/AP Photo)