MEN in patched overalls and women in freshly washed blouses walk down a narrow lane just after six in the morning. They are packed in tightly like spectators leaving a sports stadium, but this is their life, their every morning. Backs are straight; trousers and sleeves rolled up, exposing mottled yet able limbs. They crush discarded wrappers of quick-fry breakfasts under foot, corn and oil dripping from mouths. Banana skins are ground to dust by thousands of feet.

Everyone is moving in one direction, jostling and shoving, out of a maze of low-strung shacks, past shops selling shoes and phones that have already been open an hour, out into the high-rise centre of Nairobi, where factories and offices pay salaries—everyone, that is, except a limp male figure huddled in a corner strafed by the first delicate rays of the sun. He seems to wait for the crowd to pass or at least thin before he dares to swim upstream. His hair is short and shiny as if sanded down rather than cut; his shirt is in pieces. He tells your correspondent that he has just arrived from the countryside. This is not home, he says. He does not sound convinced it ever will be.

His name is Jonah Kasiri and he is 23 years old. He came to Nairobi on an overnight minibus with his worldly possessions—a battered alarm clock and an additional pair of cotton trousers—packed into a canvas bag that smells of ripe fruit. His village in Kenya’s west, as he describes it, sounds like many: a verdant clump of trees and animals where man eats what he can hunt or gather but has little chance of betterment.

For that one has to come to the city. His cousin went to Nairobi two years ago and returned for a visit last week, wearing two mobile phones in a leather pouch on the belt of a brand new pair of pleated trousers. That made an impression on Mr Kasiri. When his cousin offered to help him follow suit, he jumped at the chance.

The crowd eases and we walk into the maze of shacks. Mr Kasiri says he must relieve himself but cannot afford to. In the city nothing is free. We come to a cement floor divided into seven stalls, each with a hole. “Is it clean?” asks the customer in front of us. The proprietor, Teresia Ngusye, seated on a stool, handing out tissue paper, says she cleans every hour, pointing down the alley to similar looking shacks. “See the competition I have.” She charges us ten shillings (12 cents), which she says will go toward building a second set of toilets. Mr Kasiri nods. Everything in the city is an opportunity. He too might one day like to run such an establishment. In parting, the newly minted city boy hears a warning, “Bowel problems are expensive.”

This is Kibera. Often, and probably rightly, described as Africa’s biggest slum, it is home to perhaps a million people. Nobody knows for sure, since Kibera is left to its own devices. Government is absent: it offers the residents (regarded as squatters) no services, opens no schools, operates no hospitals, paves no roads, connects no power lines and pumps no water into homes.

To equate slums with idleness and misery is to misunderstand them

And yet Kibera, wedged in between ornate embassies and a well-tended golf course, is an integral part of Nairobi. Its residents live in a dozen villages on a piece of land half a mile wide and two miles long, draped like a bath mat on a tub across a slope falling into a man-made lake. Once the slope was wooded and each village had only a few houses. In the past 30 years they have fused to become one of the world’s most densely populated places, garnering a measure of first-world notoriety. Kibera features in the film “The Constant Gardener”, based on the eponymous John le Carré novel, as well as in a music video by Sarah McLachlan, a Canadian pop singer, representing the epitome of poverty.

Kibera’s origins are Western. A century ago British colonial rulers gave small plots of land on the edge of Nairobi to Nubian soldiers serving in the King’s African Rifles. They built mud huts below the road leading to the farm of Karen Blixen—made famous in the film “Out of Africa”, based on the Danish writer’s life. The land was later nationalised but the Nubians stayed put and rented parts of it to newcomers. Today most homes are made of ragged tin and reused timber. Walking in the warren of narrow lanes that divide them, some only shoulder-wide and all of them devoid of cars, one is reminded of a medieval European city.

At seven in the morning Cecilia Achieng leads the children in her school in prayer and song. They chirp like birds; not all have had breakfast. When lessons begin at eight, she inspects a well-thumbed ledger that records who has paid school fees. We don’t expel kids who cannot afford class,” she insists. They may be asked to rear chickens in the schoolyard and sell the eggs.

Ms Achieng has frizzy hair that forms a tall bulb and is partly dyed red. She wears large silver earrings with a baby-blue two-piece suit. The 36-year-old has given birth to four children, adopted a further two and also looks after a niece. With no public schools to send them to, she started her own four years ago. Other mothers helped her rent an empty church hall and hire teachers. She was soon inundated with children. Asking parents to pay 7,500 shillings ($87) in annual fees enabled her to move to a bigger hall. Two years later she had saved enough money to erect half a dozen primitive classrooms: cement holds in place sturdy sheets of corrugated iron known as mabati. Yellow paint gives them an uncomplicated cheerfulness.

With her charges settled in, Ms Achieng takes a mid-morning stroll. She navigates lanes that look like dry river beds. When it rains, Kibera floods. Open sewers are covered with planks worn smooth by water and constant trampling. Scavengers rake over debris before it is washed downhill. Residents burn the rest, enveloping homes in acrid smoke. Laundry on washing lines is covered in soot.

“This street was much wider a few years ago,” says Ms Achieng. Vendors line both sides, selling fresh fruit and vegetables, soap, sweets, cigarettes. They have encroached on what once was a thoroughfare, building stalls ever farther into the throng of customers. The economy is booming and incomes are rising in Kibera. “What’s playing?” Ms Achieng asks Tyson Muigai, who rents out a 600W sound system for parties, weddings and wakes, charging 5,000 shillings ($58) a day. “Happy or sad?”

We pass a shack with a sign saying, “Load music on iPods”, and another, “We do not write any local material.”. Ms Achieng explains, “They make [counterfeit] copies of Jay-Z or Beyoncé songs, but not of rappers from Kibera. We protect our own.” Around the corner John Mwangi runs a cinema with 70 plastic seats, which he fills six times a day. Ms Achieng marvels at the orange clock face on his gold watch. “I tell you, people have money,” he says.

Kibera is a thriving economic machine. Local residents provide most of the goods and services. Tailors are hunched over pedal-powered sewing machines. Accountants and lawyers share trestle tables in open-air offices. Carpenters carve frames for double beds along a railway line. Whole skinned cows hang in spotless butcher shops. “Give me 30 bob,” says a customer to a paraffin seller, who has just taken delivery of several jerry cans from a porter with a steel-frame wheelbarrow. All day long, sweaty porters cart supplies along filthy lanes, hissing to shoo people out of the way.

Life in Kibera can be harsh. Disease is rife, food is short for some, and death can come suddenly. Just after eleven o’clock an explosion thunders past the paraffin seller. Lights in the shops along the lane expire instantly, then a mob charges past, accompanied by sharp screams and a sizzling, dancing power cable that has blasted off a faulty transformer overhead. The cable eventually goes limp and the crowd disperses. Minutes later the lights come back.

The transformer, like all power in Kibera, is run by shady types who tap into the city grid. They are less than scrupulous when it comes to safety and they charge heavily. But at least Kibera has power, unlike many other parts of Africa. Soft drinks sold in shops are chilled. Rooftops are awash with TV aerials and mobile phones are as ubiquitous as in the West.

Kibera may be the most entrepreneurial place on the planet

The key to making it in Kibera is access to capital. A market of one million potential customers crowds in on entrepreneurs, but raising the money to start a business is hard. Most banks won’t lend to them because they have no collateral, perhaps not even a fixed address. Those who manage to borrow face high interest rates. Moses Mwega pays 25% a year and considers himself lucky. Over the years he has built up a cosmetics shop selling creams, wigs and shampoos. The bank recently accepted his stock, a television set and a second-hand sofa, including lace doilies, as collateral. He got 350,000 shillings ($4,000) to expand his business.

But first the 53-year-old had to join a savers club—a cross between a support group and a control organ. Late in the morning Mr Mwega sets off to attend the group’s weekly meeting, wearing black shoes as polished as his bare forehead. His skin is smooth and his hands shiny, proud testament to his choice of products, he says. He joins a dozen men and women in a dank shack to receive instructions on record-keeping. Then they inspect each other’s books—no secrets. Mr Mwega takes in 15,000 to 20,000 shillings a week and pays 7,000 shillings to the bank. He will be done in 15 months. “Then I will get a proper loan,” he says.

After the meeting we have lunch at the Katulani café, a bare room with an anaemic roof that lets in daylight and fresh air. Guests sit on wooden benches and talk over each other. Most are penniless students who call this “the campus”. Boniface Ngewa, the owner, serves chapati bread and sukuma wiki, a leafy vegetable whose name translates as “push the week”, which is how long it is said to last. He goes through 100lb of flour a day, serving 3,000 customers.

In Kibera everyone eats out, Mr Ngewa says. Home-cooking is a luxury. The poor have no capital and cannot buy food in bulk. A single portion of charcoal to cook a meal costs at least 20 shillings (23 cents). Employing cooks, on the other hand, is cheap (300 shillings a day) and café prices are low. Mr Ngewa charges 30 shillings for a meal. An hour later when we leave the café, as if to prove his point, the lane outside resembles a food court: countless stalls have fired up pots and pans; vendors fan grills laden with nyama choma (cooked meat) and throw potatoes into roiling fat.

In the afternoon, school is out and Ms Achieng turns to her second career. She is in the food business too, but as a caterer. She regularly cooks for private functions attended by 500 people, and has served as many as 1,600. “Funerals are a good business,” she says. Couples getting married are too picky. They do not want plastic plates and Ms Achieng cannot yet afford to buy her own ceramic ones. “I have bid for a few weddings but didn’t win the tender.”

Kibera may be the most entrepreneurial place on the planet. Residents have no choice but to look after themselves. If they want to escape poverty—and have the necessary drive—they will try to strike out on their own. Ms Achieng has a third career as a hairdresser. When she has a free moment she goes from door-to-door and braids, earning 250 shillings ($3) in two hours. Regular clients call on her by mobile phone. At the annual Miss Kibera beauty pageant she is the lead stylist.

Does Mr Kasiri, the new arrival, have what she has? He finally finds his cousin after wandering the dusty lanes for hours. Kibera is bigger and denser than he had imagined. Every speck is in use. Residents have started building second storeys to expand upwards. In the Nubian language, kibera means forest, but there are no trees left. The country boy stands at an intersection and looks left and right and left again. His cousin has arranged for him to meet a man about a job. But where is he? Mr Kasiri looks tired. His luxuriant hair is covered with flakes of ash from a rubbish fire. At least he no longer waits for crowds to thin; he plunges straight in and gropes his way past wheelbarrow porters, careful to jump out of the way when their sharp-edged carts swivel around. Talking about jobs he would like to do, a note of excitement creeps into his voice. “I could repair stoves. I saw a man do that,” he says. His cousin whistles and shakes his head. “Where will you get tools? Who will pay for them?” Around six in the evening Kibera fills up to bursting point. The tens, or perhaps hundreds, of thousands who left in the morning for faraway offices and factories are returning. To save money, prim secretaries and exhausted labourers walk back rather than take a bus. Their wages are meagre and yet in compound several million dollars walk into the slum every night. Kibera is an African version of a Chinese boomtown, an advertisement for solid human ambition. Like Guangzhou and Xiamen, it acts as a magnet for talent from rural areas, attracting the most determined among young farmers. To equate slums with idleness and misery is to misunderstand them. Two out of three Nairobians live in one, half of them in Kibera. Officials occasionally try to evict squatter-residents but many fight back, with the help of Muungano wa Wanavijiji, their own lobby group. In “Shadow Cities”, a book that describes a tour of slums across the globe, Robert Neuwirth recalls that New York’s Upper East Side was once a shantytown and suggests that all bright shining cities start as mud. Slums are far from hopeless places; many are not where economic losers end up, but rather reservoirs of tomorrow’s winners.

The pace of commerce on Kibera’s streets picks up with the setting sun. Jane Nzembi sells cereals to mothers cooking dinner; she holds cobs of corn with both hands and twists them in opposite directions to strip off the husks. Ruth Chesi refills buckets of charcoal as soon as they are empty. Carolina Awuor’s electric maize mill—rented for 15,000 shillings ($175) a month—runs nonstop to make flour for ugali buns.

When the vendors eventually close down around eight o’clock they deliver their cash receipts to nearby mobile-phone stores. Kenyan phone companies double up as banks; they take deposits and transfer funds. After decades of being excluded from banking, slum-dwellers now move their money fast and often; they no longer keep it under a mattress.

Mr Mwega, the cosmetics man who took out a loan, closes his store at nine, having eaten already at his counter. Through a curtain he slips into his windowless living room at the back of his streetside shack. An electric Christmas tree is perched on a stereo. He removes his polished shoes and rests them on a low table. He is halfway through reading “The Last Don” by Mario Puzo but says he prefers the thrillers of James Pattinson. He keeps a thick dictionary by his side.

The room is immaculate, as are those of many neighbours. Kibera only looks like a slum from the outside. Mr Mwega’s wife fetches water from a privately run street tap, paying a few shillings to fill a 20-litre jerry can, and does the washing up. Mr Mwega says in the wealthy parts of Nairobi the residents get municipal water and pay a tenth of what it costs here. “But still I’m not moving. My friends and my business are here.” The evening is reserved for leisure, and leisure is good business. Barber chairs are never empty more than a few seconds. Ogola Simenon, whose salon is five feet high and about as wide, calls this the rush hour. Customers keep coming through his diminutive door. “Pray, why not in daytime?” He charges about 40 shillings (46 cents) to snip, shear, crop and clip. Economists define the African middle class as people earning at least $100 a month—that is many of his customers. They have a little money left over after paying for food, rent and school fees. All manner of paid entertainment is available in Kibera. Some residents drink changaa, a moonshine made in backyard stills. Blindness is one of the lesser side effects. One step up is busaa, a fermented maize drink made on site in bars like Mama Sarah’s. The bar uses half-litre tin cans instead of glasses to serve customers. Many are cost conscious, says a waiter, John Wasilwa. When the price of maize goes up the bar owner cuts a strip of tin from the top of each can. The punters prefer that to higher prices. And it does not seem to slow their consumption. Around ten o’clock several of them have bedded down blearily on the mud floor next to a plastic sheet filled with roasted maize. Others throw empty tin cans at waiters. Mr Wasilwa fires them back. Better-off residents congregate at beer taverns with cement floors and cushioned seats. The aspirationally named Pentagon features a large poster of Barack Obama, celebrating his Kenyan origins. Talk is of politics and sport. This could be almost anywhere. One group of patrons is drinking draft beer and debating why busaa joints are so rowdy. Often those people have not eaten, says one. “Straight to their head,” crows a carpenter with more than a hint of superiority.

During the day, Kibera is a rough place but a safe one. Guns are rare. No tolls are charged, no protection fees paid. Most of its markets are free of cartels. The slum is so vast and diverse that no ethnic group dominates it. But what is a virtue during the day turns into a danger at night. With nobody ruling the roost, muggers and thieves have a free rein. Some residents have installed metal gates at the entrances to their alleys and lock them at midnight.

Leaving the Pentagon, your correspondent is persuaded by concerned patrons to hire a watchman as an escort. He is summoned by mobile phone and turns up in minutes, dressed in red-and-white beads and a red cloth and carrying a spear and a torch. Most watchmen in Kibera are Masai. They have a reputation for fearlessness and loyalty—for which they are paid 50 shillings (58 cents).

Walking through empty streets we hear music doodling behind thin walls. Life happens indoors now. Most people are too scared to even visit a public toilet at night. Those who need to instead use a plastic bag at home and throw it over a wall. This is known as a “flying toilet”. Anyone out walking late is advised to look up as well as down.

We bump into Edith Nyawate, a vegetable seller escorted by another Masai watchman. She sets off to the wholesale market in the city centre every night around this time to buy produce when it opens and bring it back to Kibera at daybreak. She is tired, she says, but does not want a daytime job in a factory. “Maybe they pay you 50 bob but that’s not enough for school fees.”

Slum business runs around the clock. An electrical workshop is finishing a rush order at three o’clock. A lone baker’s face is illuminated by the earthy glow of his cavernous wood-fired oven. A tithe-hunting preacher, Augustus Omiti, is holding an all-night vigil at a shack church with a sturdy gate. His congregation is locked in until morning, singing and dancing—for their own safety, he cackles. They have nowhere to sit because he has rented out the church’s plastic chairs for 1,000 shillings ($12) to a wedding that is taking place nearby. Nonetheless he has high hopes his flock will donate generously.

The Masai watchman, who alone among residents refuses to divulge his name, takes your correspondent to where many of his nightly journeys end. We knock on the door of the Stage Inn, a spot for revellers to bed down for a few hours—for 300 shillings ($3.50). A dimly lit corridor bordered by sheet-metal walls leads to two dozen rooms with sagging beds, many of them unmade and recently vacated. Who would depart at this hour? The Masai and a hotel porter exchange glances. A young woman in a light dress passes us on the way to the communal washroom.

Worried about getting home at night? Phone a Masai Emmanuel Mukhoa, the 35-year-old porter, hears a knock on the front door and walks over to a peephole, then opens up and hands a room key tied to a black shingle to a drunk, older businessman with a girl in tow. “I know most of the guests. They come at all times,” he says, and adds wistfully, “wish I was one.” Mr Mukhoa is a rarity, a salaried worker employed within the slum. He is paid 5,000 shillings ($60) a month. His hours are long but regular, his financial risk minimal, yet he dreams of running a business, like his guests. The new day in the slum starts by five o’clock. Alarms echo down dark streets, drowning out what little music is left from the night. Ms Achieng rouses herself and then the brood of children that surrounds her on the floor, washes them and erects her frizzy dome of red and black hair. She can afford to feed her children but mornings are always chaotic and some of the older ones miss breakfast. Heading to school, they join the ranks of workers walking to one of Kibera’s eight exits and on to jobs in Nairobi proper where buildings rise higher than just one or two floors. The shoving and jostling resumes. The lanes are bursting with people by six, all heading in one direction. Among them is Mr Kasiri, the new arrival. He has been promised work on a construction site and is following a foreman through a world that has yet to fully reveal itself to him.

Mr Kasiri is amazed that among the people surrounding him is not one face he recognises, not one man who would lend him a few bob. Yet nor would any of them tell on him if he spent his wage on a bottle of changaa and got drunk tonight after his shift. They do not care. There are just so many of them squeezing through the gate; they crowd in as if celebrating a festival, yet few talk to each other or even look up. They are not unhappy, at least most of them are not. They have jobs to do and things to buy. Last night he talked to a man who sells stoves and learned that broken ones are cheap and easy to repair. Soon he will try his hand. He finds the idea of going back to the village hard to imagine.