What they don’t tell you about Varanasi, probably India’s holiest city, is that in addition to being filled with sacred temples, mischievous monkeys and bearded ascetics, it’s also full of waste of all kinds: mountains of fetid cow and other, much worse kinds of dung, muddy tributaries of dubious origin, mounds of fast-decaying flowers, shards of shattered clay cups. As I left the utter squalor of Varanasi, a permanent and ancient city of four million, for a temporary religious celebration of even more people nearby, I could only imagine the enormous crowds, inescapable filth and utter chaos that it would produce.

It was January, and I was headed 80 miles west to the Maha Kumbh Mela in Allahabad, a Hindu religious festival in which tens of millions of pilgrims come together at the convergence of two real rivers, the Ganges and the Yamuna, and one mythical stream, the Saraswati. They stay for all or part of a celebration—this year’s would last 55 days—that is the largest single-purpose human gathering on earth.

In the mythology of the Kumbh Mela, gods and demons fought for 12 days over a pitcher (kumbh) of nectar of immortality from the primordial ocean, and the nectar spilled onto the earth at four different places, including Allahabad. The gathering (mela) takes place every three years at one of the four locales in a 12-year cycle—a day of the gods’ time corresponds to a year of human time—with the largest (maha) celebration in Allahabad. The first written record of its occurrence dates to the seventh century A.D.

The iconic image to which the Maha Kumbh Mela is invariably reduced is that of millions of worshipers, their ash-covered, dreadlocked sadhus leading the way, converging on the bank of the Ganges for a collective dawn dunk. This spectacle is so overwhelming that it was almost impossible for me to find out what the rest of the vast gathering would be like. And so I had approached my visit to Allahabad with both awe and dread. After seeing the sordid streets of Varanasi, the dread was winning out.

I arrived by taxi at the Kumbh at sunset, expecting throngs of cars, cows and human beings blocking all access points. Instead I glided comfortably into my camp, which sat on a hilltop. I looked out over the fleeting city before me: makeshift shelters constructed on the floodplain of a river that was sure to overflow again in a few months. The soundtrack consisted of dissonant chords of shrill songs, snippets of amped-up holy recitations, a distorted line from a dramatic performance of an Indian epic and the constant rumble of millions of people cooking, chatting, snoring and singing. The horizon was dark and smoky red, with colorful flickers of light piercing the haze in orderly, geometric rows that stretched as far as I could see in three directions.

I’d come to witness the spectacle for myself, but also to meet a group of Harvard researchers from the university’s Graduate School of Design. Led by Rahul Mehrotra, an architect from Mumbai before he went stateside to teach, they would closely analyze this unparalleled feat of spontaneous urban organization. “We call this a pop-up megacity,” said Mehrotra, a bearded 54-year-old. “It’s a real city, but it’s built in just a few weeks to instantly accommodate tens of millions of residents and visitors. It’s fascinating in its own right, of course. But our main interest is in what can we learn from this city that we can then apply to designing and building all kinds of other pop-up megacities like it. Can what we see here teach us something that will help the next time the world has to build refugee camps or emergency settlements?”

Mehrotra gave me a rundown on the place and urged me to plunge in. “It’s the biggest religious shopping mall in the world,” he said. “Every kind of different Hindu group you can imagine comes together here to show off their wares, share their knowledge and vie for disciples. You have to get down there and see for yourself.”

***

What struck me as soon as I descended into the byways of the Kumbh was something I had not anticipated: It was the cleanest and most orderly Indian city I’d ever seen. Wide boulevards built from metal plates bisected long lines of tents. White splashes dotted the sand where sanitation workers had disposed of waste and then scattered lye. The grounds stretched so far and wide, nearly eight square miles, that there was, at that time, none of the crowding and claustrophobia I’d feared. Clean and orderly streets were inhabited by citizens apparently enjoying an evening of enlightenment from lecturing gurus or entertainment from costumed Ramayana actors. There was little commerce of any kind, save for the occasional street-side snack stand that sold fried potatoes or popcorn, and there was little or no traffic, as vehicles were restricted. Pedestrians seemed to move with purpose, proceeding from mess hall to music performance, from the feet of their gurus to the tiny warming fires they’d lit in front of their tents.

That night, as I wandered the streets of the Kumbh—housing, lecture halls, open-air cafeterias, meeting areas for sadhus, disciples and pilgrims—I tried to make sense of the layout, a grid of 14 designated sectors. Mehrotra and his co-workers had mapped out the Kumbh’s center, sent around a video van to document the main streets and flown kite cameras high above the crowds to capture the event from yet another perspective.

The next day I walked with them across the main permanent bridge to Allahabad. From up here, high above the pop-up city, we could get a better feel for its composition. “They create a completely gridded city on top of this shifting floodplain,” said Mehrotra. “And the way that they impose this grid on the river is by building 18 small pontoon bridges that crisscross the Ganges and Yamuna, allowing the grid to go on, even across the water.”

On one side of the bridge we could see what was called the Sangam, the holy bathing area, where the two large rivers came together as one. Sandbags fortified the banks; fences in the mid-stream bathing areas kept pilgrims from drifting down the river. “Before 1954 the Sangam area was much, much smaller,” said Mehrotra. “But at the Kumbh Mela that year there was a terrible stampede in which hundreds died. After that the authorities decided to expand the Sangam and reduce the chances of that happening again.”

Below us, between the bridge and the bathing area, was Sector 4, where the 16 major akharas, Hindu religious organizations, had their headquarters. Across the water, on the other side of the bridge , was the temporary administrative center, with a hospital, portable ATMs, a shuttered Kumbh history exhibit and an open-air market for food, clothing, religious goods and souvenirs. Going away from the Sangam, on the other side of the bridge, stretched more and more tent cities. “Think of it as an ordinary city,” said Mehrotra. “Over there is the downtown where the biggest and most important groups reside and where everyone comes together, in this case to bathe in the Ganges. Behind us are the suburbs, more sparsely populated, farther from the action, with all kinds of other, different groups living out there. Some gurus choose to be out there so they can be away from the maelstrom and gather quietly and peacefully with their followers. Others are relegated to the margins because they don’t have the clout to get a place in the center. It works just like any other city. Except that it’s all built, lived in and then dissembled in a matter of a few months.”

The government of Uttar Pradesh, the Indian state in which Allahabad is located, runs the Mela. This is a prestigious posting, and government officials spend years planning the event. On the private side, the most powerful akharas seem to take a lead role organizing the central sectors and deciding the order in which they will proceed to the Sangam on auspicious bathing days. The Kumbh Mela works in a way that most other Indian cities do not in part because everyone is on their best behavior: Civil servants know that their careers will be defined by these few weeks in the national spotlight; members of the public arrive with a sense of purpose and community.

One other quality that Mehrotra was quick to point out was the population fluctuation. On ordinary days probably two million to five million showed up. But on the auspicious bathing days, of which there were nine, with one of primary importance, the population could easily reach 20 million to 30 million, according to news reports. I asked Mehrotra how this place managed to function so well, especially in contrast to so many permanent Indian cities. “The Kumbh Mela is like an Indian wedding,” he said. “You can do things at this level of intensity only because you know it will be over soon.”

***

On the eve of the next auspicious bathing day, the air of the Kumbh Mela was so smoky from countless wood cooking fires that my eyes teared up. The streets were bustling long into the night as pilgrims stumbled off trains and buses and walked to their camps. The next morning, before dawn, I made my way to the bathing area. The bathers were quiet, but shrill police whistles pierced the air, warning pilgrims to stay near shore and to swim only in designated areas. Along the perimeter of the beach priests had set up stations to sell their services, helping pilgrims with their rituals before they waded into the Ganges. It was certainly more crowded now at the Sangam than at any other time since I’d been here. But it was very hard to gauge the numbers.

The truth is that the claims that 20 million or 30 million people a day bathe in the Sangam, or that 120 million people visit the Kumbh over the course of the event, are hard to substantiate. The government authority that runs the Kumbh Mela has an interest in making these numbers seem as big and as bombastic as possible, to validate its efficacy and ensure greater funding next time. The news media in India and abroad also thrive on the event’s extreme nature, so they, too, have little reason to challenge the numbers.

Whatever the actual number of people that morning, the city remained orderly. There was some congestion down at the front lines of the flowing river, but it was more like crowding of the kind you’d have seen on a hot summer afternoon on Coney Island in its heyday, not the jostling, compression and danger of a stuffed soccer stadium.

Once the crowds dispersed, the banks of the Ganges were clogged with dams of garbage, including flowers, food, plastic bottles and unidentifiable objects. One guru who spoke to the Harvard group confided that though he would never tell this to his followers, he no longer bathes in the Ganges at the Kumbh Mela. “It is a sacred river,” he said, “but that doesn’t mean it’s pure.” At least one member of the Harvard team contracted bilharzia, a parasitic infection, after bathing in the Ganges. There are efforts to clean up the water, most notably the green Ganga movement headquartered at a camp just opposite the Sangam.

On my last morning I traveled to the central sector where the 16 major akharas were located. The Juna akhara is the most powerful and influential of these. Inside a large compound, consisting of orange tents arrayed around a massive orange flag hoisted high above the encampment on a pole, the sadhus sat next to fires that their disciples helped keep burning day and night. The first sadhu I saw was a peculiar sight: a bearded, dreadlocked white guy smoking a stone chillum filled with hashish who, after he exhaled, began speaking with a distinctively American accent. Baba Rampuri, a 63-year-old U.S. native raised in California who joined the Juna akhara over 40 years ago and has since ascended its ranks, gestured to me to sit down before him. One of his followers, also clad in the orange robes of the akhara, prepped and passed Rampuri another chillum of hashish, which sadhus smoke as part of a holy ritual to improve their focus while meditating. He carefully wrapped a piece of white cloth around the bottom hole and proceeded to inhale deeply before passing it along to another follower.

“This event is almost always described by the Western media as this huge gathering of the superstitious and primitive masses,” he said. “But I would contend that if you compare the people here to their equivalent in Europe or the United States and assess them with the yardstick of culture, you’d see things very differently. If you look at the number of different kinship terms people use, or the sophisticated storytelling culture they have, then you realize that these are not ignorant people drawn here by blind faith.” Like Mehrotra, he recognizes that there is a deep knowledge and intelligence at work in the Kumbh Mela that doesn’t boil down to spectacles—or miracles. Rampuri told me about his first Kumbh Mela, in 1971, when there were no latrines, little running water and only the most basic tents. I asked whether in creating the vast and relatively modern city at this year’s event, some of the essential spirit of the Mela has been lost. “How do you effectively pass your traditions down through time,” he said. “You can’t just keep things as they were. Stasis is death. You have to be dynamic to survive.”

***

A couple of weeks after I left the Kumbh Mela, on the most auspicious bathing date, February 10, crowds coming from the railway station converged on a small bridge at the edge of the Kumbh grounds and a stampede ensued, killing at least 36 people. What exactly started the stampede and why it got so bad remain a mystery. When I met Mehrotra a couple of months later in Cambridge, we talked about the tragedy. “It’s terrible and regrettable, of course, and there are some crowd management techniques that, if implemented, would almost certainly have prevented that, but I don’t think it means that we can’t learn from the good parts of this pop-up megacity, of which there were many.” He proceeded to describe what he and his students had concluded after sifting through their documentation of the event and comparing it with other pop-up cities, everything from refugee camps to Burning Man.

“When you look at structures like refugee camps, you often see everything planned out in advance, with rows of identical houses built for refugees to just move right into,” he says. “But the theory of urban planning for the Kumbh Mela is very different. The authorities provide the infrastructure—roads, water, electricity—and they divvy up the sectors between groups. But each individual organization has to build out their own space, which makes for much more of a community than when you just move people into something you’ve built for them. There’s some rigidity to the Kumbh Mela planning system, with its preordained grid structure and its map of the sectors and their essential resources ahead of time, but there’s also a profound flexibility. Individual communities can shape their spaces to be exactly as they want them to be. And that combination works.”

The Kumbh serves to expand Mehrotra’s knowledge of what he calls the kinetic city. Traditional architecture, Mehrotra said, looks at the planned, built and permanent structures that constitute the formal, static city. But increasingly, especially in places like India, a second kind of city shadows the traditional one. The kinetic city is made up of things like informal settlements, shantytowns and improvisational market areas erected in a transitory fashion without official planning or permission. In many small- to medium-sized cities of the developing world, which Mehrotra sees as vital to our future, you have a large rural population, much like most attendees of the Kumbh, flocking to newly expanding cities and often ending up in the kinetic, informal areas. He hopes his research can inform how city governments or urban planners respond to these new waves of often unforeseen urban expansion.

“There are a few central insights,” he says. “First, you need flexible infrastructure that can be rapidly deployed for sanitation, transport and electricity. Second, public-private partnerships can work if it’s very clearly understood what each side will do. Here the religious groups knew exactly what they would get from the government and what they would have to fill in for themselves. Third, we can see that when there is a common cultural identity, as there is among the Kumbh Mela attendees, it means that they can much more easily conform to the norms of a new place and live together.”

What’s most interesting to me about Mehrotra’s insights is that he has found such practical wisdom woven into the fabric of the gathering. That this public-private conglomeration could pull off such a massive event is no small achievement and, as Rampuri, the California-raised guru pointed out, it’s not clear we’d be able to stage an event of this magnitude in the West. Can you imagine, he asked, if millions and millions of people suddenly descended on Kansas City?