There is a long curve of water and, as far as the eye can see, there are shacks, garbage, washing, tin, bits of wood, scraps of cloth, rats and children. The water is grey, but at the edges there's a flotsam of multicoloured plastic rubbish. This is the Estero de San Miguel, the front line in an undeclared war between the rich and poor of Manila. Figures emerge from creaky doors to move along bits of walkway. In the deep distance is the dome of a mosque; beyond that are skyscrapers.

Mena Cinco, a community leader here, volunteers to take me in - but only about 50 yards. After that, she cannot guarantee my safety. At the bottom of a ladder, the central mystery of the Estero de San Miguel is revealed: a long tunnel, four feet wide, dark except for the occasional bare bulb. It's just like an old coal mine, with rickety joists, shafts of light and pools of what I'm hoping is water on the floor. All along the tunnel are doors into the homes of as many as 6,000 people.

We knock on the first one that's ajar. Oliver Baldera comes blinking to it, pulling on his shirt. On the floor behind him are his four kids, eating ice cream. His wife joins him.

The room is eight feet by eight and forms their entire dwelling space. It contains everything they own: a television, four bowls of ice cream, a light bulb, a mattress and the clothes they are wearing. "We've been here more than ten years," he says. "There's no choice. I'm a carpenter in the construction industry. We came from Mindanao."

Why did he move? "Because of poverty. It's easier to get a job here and I can earn 400 pesos a day. I can send the kids to school and they eat three times a day - but it's not enough. I need more space."

“But they're happy," Mena chips in.

Further along, there's a shaft of light and some kids are splashing about in a blow-up pool. Mena makes them sing. One of them comes up to me. "What's it like living here?" I ask. Mena mutters something to him in Filipino. "Happy," he says, and smiles.

This is a place where you cannot stride along without hitting your head or bruising your elbow, so people creep and shuffle. Here, you cannot go to the toilet without standing in a queue. Here, sex between a man and a woman has tohappen within breathing distance of their kids and earshot of 20 other families. This is the classic 21st-century slum. A billion people live in them, one in seven of the world's population. By 2050, according to the United Nations, there could be three billion. The slum is the filthy secret of the modern mega-city, the hidden achievement of 20 years ofuntrammelled market forces, greed, neglect and graft.

Yet Mena, at my elbow, is feeding me an incessant mantra: "We are happy; there is social cohesion here; we are organised; it is clean." The reason is this - the Estero de San Miguel has been condemned. The president of the Philippines, Benigno "Noynoy" Aquino, has decided to clear Manila's slums and send half a million people back to the countryside. That suits the business elite and the political clans that run the country fine. "Many of our people are no longer interested in agriculture, so we need to give them incentives to go back," says Cecilia Alba, head of the national Housing and Urban Development Co-ordinating Council. "If we had to rehouse the slum-dwellers inside Manila in medium-rise housing, it would cost a third of the national budget."

At the top of the list for relocation are the residents of the Estero de San Miguel. They will not go without a fight. "We will barricade and we will revolt if we have to," Mena says. "We will resist slum clearance and we will fight to defend our community. We are happy here."

This is not an idle threat. On 28 April, residents of the Laperal slum a few miles away engaged demolition teams with Molotov cocktails and guns in a riot that injured six policemen and numerous slum-dwellers. An arson attack had wiped out most of the area's dwellings ten days earlier.

Technically, global policy is on the side of the rioters. In 2003, an influential UN report, entitled The Challenge of Slums, signalled a shift away from the old slum-clearance policies and recognised that informal settlements make positive contributions to economic development. They house new migrants; because they are dense, they use land efficiently; they are culturally diverse; and they offer numerous opportunities for ragged-trousered entrepreneurs.

“Ten years ago, we used to dream that cities would become slum-free," says Muhammad Khadim of UN-Habitat. "The approach has changed. People see the positives. The approach now is not to clear them but to improve them gradually [and] regularise land tenure."

Cameron Sinclair, who runs the non-profit design firm Architecture for Humanity, goes further. "A slum is a resilient urban animal. You cannot pry it away," he tells me. "It's like a good parasite. There are some parasites that attack the body and you have to get rid of them but, within the city, the informal settlement is a parasite that acts in harmony with the city, keeps it in check."

Sinclair, whose organisation has upgraded slums in Brazil, Kenya and South Africa, believes that modern city design should not only tolerate slums but learn from them - and even emulate them. "To be honest, what we lack in a place like London is that the lower classes can't live in central London and have to commute for two and a half hours to do the jobs that keep people going."

What has driven the new thinking is ugly economic facts. After the 1970s, there was a sharp slowdown in the provision of social housing. The free-market revolution in the cities has led to the retreat of state provision, the rise of the informal economy and the rapid impoverishment of the rural poor. As a result, we are having to ask ourselves a question that would have made the 19th-century fathers of city planning shudder: do we have to learn to live with slums for ever?

It's a question to which the Filipino political elite have defiantly answered no.

“Should I buy them ice cream?" Regina "Gina" Lopez asks me, tilting her white Stetson as she leads me through what is left of a slum called the Estero de Paco. Teenage boys wearing hip-hop clothes and baseball hats are crowding, shirtless, around Gina. It's one of their birthdays, so should she buy them ice cream? Gina's trouser suit is the colour of ice cream. She is lithe, slinky and 61 years old. Among the 30 people with her are two cops, a media team of six, guys from the local community, her bodyguards, factotums and a man in dark glasses who is carrying her handbag.

Gina is a TV star, philanthropist, boss of the Pasig River Rehabilitation Commission and, most importantly, a member of the Lopez family. Lopez Inc owns much of downtown Manila - the energy company, a TV empire, a phone company - and has interests in all kinds of infrastructure, including water. Who better than Gina, in a country untroubled by worries about conflict of interest, to lead the forcible removal of slum-dwellers from the waterways?

The Estero de Paco used to have slums right down to the water's edge, just like the San Miguel. Now, instead of shacks, there is a neat border of agapanthus and rubber plants. State-of-the-art oxidation units are turning the brown sludge into something chemically close to H2O. Into the space that has been cleared, work gangs are laying a wide-bore sewage pipe.

As Gina approaches, a group of women from the slum falls into line and salutes. The women are middle-aged and poor; their T-shirts bear the words "River Warriors". They stand to attention and Gina, Prada-clad, goes into a drill routine: "River Warriors, atten . . . shun!" Then there are slogans about honour and playing for the team and some more of the drill, before they all fall about laughing. "I ordered them to dive into the water," she giggles.

The idea behind the River Warriors is serious. The clearance of the Estero de Paco was "non-negotiable". The Warriors' job is to make sure that those who have been cleared do not come back. "They will poo here! They will throw garbage," Gina says. "They would come back, if we didn't guard the place. So we work with the ones who are compliant. To make a change like this, you have to work with a chosen few, the vanguard."

The clearance programme works like a giant scalpel. Four metres of land is all that is needed to create the easement for the waste pipe, so a second, deeper layer of slums remains - you can see where something has sheared through walls, windows, dirt, alleyways. This is social engineering on a vast scale. It's what the government has decreed for half a million people. Like the slum-clearers of 19th-century London and New York, Gina has a missionary enthusiasm. "You can't live well if you're faced with the constant smell of faeces, right? You can't live a decent life on top of a sewer. Even if those people want to stay there, [they can't because] it has a wider impact on the city, the environment: we can't clean the water and bring the river back to life if they're there; the crime and sickness have a big impact on the environment."

With Gina out of earshot, two of the River Warrior women quietly tell me that they are secret returnees. They were moved on to a place called Calauan, four hours away by road, but have come back. I demand to see Calauan. "No problem," says Gina, flipping open her mobile phone. "Get me aviation."

The chopper skims low across Manila Bay. It's fringed with slums and, out in the bay, there are homes on stilts. "Even the sea is squatted," Monchet Olives, Gina's chief of staff, tells me. Soon, the skyscraper outline of downtown Manila disappears. We're above rice paddies; in the distance, there are mountains. Calauan comes into view - neat rows of single-storey housing, their tin roofs glinting. The whole complex houses about 6,000 families and there is room for many more.

On the streets, density is not a problem. The public space is deserted. There's a playground; there's a school with the name Oscar Lopez painted on the roof. The problem is - as Monchet concedes - there is no electricity, no running water and no prospect of ever getting any. And no jobs. "When it comes to electricity, we're between a rock and a hard place," he says. "Many of the new residents have never been used to paying bills, and the electricity company, to make the investment, needs an income stream that they just can't provide."

I notice that we're being shadowed by two soldiers, in camouflage and with assault rifles, on motorbikes. "That's because of the New People's Army. Guerrilla activity is what made them abandon this place for ten years."

Deep in the jungle? "No, just up there on the hill." Monchet waves his finger in the general direction of the landscape, which suddenly looks a lot like the treeline in the opening credits of Apocalypse Now.

Ruben Petrache was one of those who moved here from the Estero de Paco. He is in his fifties and has been seriously ill. His home is a spacious terraced hut. It has a tin roof, tinfoil in­sulation to keep the heat down, a pretty garden and a "mezzanine" arrangement that creates two bedrooms, such as you would see in a loft. Ruben's English is not so good, so Monchet translates: "What he's saying is that although the community is disrupted, he thinks it's better here. For him, at least. Once you get here, after a while, you realise that you'd become accustomed to conditions that were insanitary. You learn to move on, live in a new way."

For electricity, he points to the solar panel; for water, to the barrel collecting rainwater on his porch. Are there any downsides?

“It would be better if there was a factory here, because we need more jobs," Monchet summarises. Later, with a translator, I work out what Ruben, hand-picked by the camp's authorities, was trying to say: "What the people need is a job. We need a company nearby so that we don't have to go to Manila. Also, we need electricity. Many residents here know how to fix electric fans, radios, but the problem is, even if they have the skills, they cannot [use] it because there is no electricity here - so they are forced to go to Manila to find work and earn money to buy food.

“We are hard workers. If we don't do anything, we might die of hunger here. That's why many go back to Manila: to look for work and earn money."

In the covered market, the stalls are stocked with meat, rice and vegetables but there are more stallholders than shoppers. Gloria Cruz, a 38-year-old mother, is holding forth on a kara­oke machine to three toddlers, two other mums, the ArmaLite-toting soldiers and me. After a couple of verses, she hits the pause button. "My husband goes to Manila to work," she says. "He comes back at weekends. It's the same for everybody. There's nothing here."

Felino Palafox is an architect who specialises in the construction of vast, space-age projects in the Middle East and Asia - mosques, Buddhist temples, futuristic towers on the Persian Gulf - always for people with money to burn.

Now, however, he wants to save the Estero de San Miguel: to rebuild it, in situ, with new materials. The plan is to clear it bit by bit and put inmodular housing. Each plot will be ten square metres; the ground floor will be reserved for retail and tricycle parking, the floors above extending out above the walkway, just as slum-dwellers build their homes - "stealing the air from the planning authorities", Palafox calls it. "The slum-dwellers," he adds, "are experts at live-work space design. They spontaneously do mixed-use! We just have to learn from them."

From the roof of the tower block in Makati, the central business district, where his practice has its headquarters, he gives me a primer in what has gone wrong. He indicates the neighbouring tower blocks - "monuments to graft" - and the gated compounds downtown where the rich live. To the government, which says his design is too expensive, he says: "OK, the total cost of rehousing slum-dwellers in situ is 30 per cent of GDP [but] I calculate we lose about 30 per cent of the country's wealth through corruption. If we didn't have corruption, we wouldn't need to tolerate slums." He sees the Estero de San Miguel as a test case: if he can make it work there, it's scalable to each of the city's riverside slums. So the stakes are huge.

Father Norberto Carcellar, who has worked for much of his life with Manila's poor, thinks that the elite are engaged in a huge self-deception about the question of slum clearance: "We have to recognise the value of slum-dwellers to the city. These are the ones who drive your car, clean your house and run your store. If these people were cleared from the city, the city would die. Slum-dwellers add social, political and economic value to the city."

That sentiment would have seemed alien to our grandparents' generation: I can still hear mine, brought up in Edwardian poverty in a coal and cotton town in northern England, spitting out the word "slum" with disgust. For them, slums meant a dog-eat-dog, dirty world where solidarity could not flourish and people lived like animals and treated their kids worse. Thirty years of globalisation have produced something which defies that stereotype. With Mena at my side, I'm about to witness it.

As it is Saturday night, there is a full complement of beefy guys with sticks, rice flails and flashlights - the volunteer police force of the Estero de San Miguel. Mena and I turn off into an alleyway opposite a McDonald's. You would hardly know it's there. The passage narrows, jinks around, and suddenly it feels as if I am in a novel by Charles Dickens.

On a bridge that is less than a metre wide, a man is squatting beside a barbecue. Because of the smoke, I don't see that it is a bridge until

I'm on it, or that below us is the canal, which is about two metres wide here. The dwellings are built so close together that the mothers peering out of the upstairs bedrooms, made of wooden boxes, could shake their neighbours' hands. If you'd decided to remake Oliver Twist as an expressionist film and this was the proposed set design, you would probably sack the designer, saying: "It's too much, too grotesque."

We head down into the tunnel, stooping now, because it is less than five feet high. After passing a poker game and a stray chicken, I come to a store that is run by Agnes Cabagauan. It sells the same things as every slum store in the world: sachets of Silvikrin hair product, Cif, Head & Shoulders shampoo, the Filipino version of Marlboro cigarettes, lighters, tampons and chewing gum. "My parents helped me set up [the store] to pay for my education," Agnes tells me.

What are you studying?

“Business admin. I have a degree. I also have a day job in a large corporation - coding in a sales department."

And you live here? "Yes. I was born here." She is 22 years old.

Then we run into Mena's son; he's an engineering student. As we cross another bridge, the unmistakable whizz and pop of something digital come blasting across the stagnant water. It's an internet café. There are nine computers crammed into a plywood hut. A dog yaps and runs around; the light is harsh. Some kids are on Facebook. Others are playing online poker. One young woman is doing her CV, another is engrossed in a game called Audition. She, too, is at college, she tells me, multitasking between her BlackBerry and the game.

Business admin? Yup.

In the space of a hundred yards, I have encountered three graduates, a DIY police force and the social media revolution. As I become used to the smoke, the wail and chatter of children, the chickens and the confined space, I learn what a billion people have had to learn: it's not so bad. "Other places have prostitution. We don't," Mena says. "We get drunks and a bit of drug-taking but it's under control. We look out for each other. We can see everything that happens - it's one big family. The main job for the volunteer police force is to look out for arsonists. Settlements under threat of clearance have a habit of getting burned down." As she discourses on the fine details of social policy in the five-foot-high niche that is her living room and kitchen, I ask the question I should have posed when we first met. How did she become so politically literate?

“I majored in political science at the University of Manila."

What slum-dwellers have produced (and I've seen it not just here but in Cairo, Nairobi, Lima and La Paz) is something the slum clearance tsars of yesteryear would not recognise - the orderly, solidaristic slum, or what the UN calls the "slum of hope".

The debate, at the global level, is no longer about how fast to tear these places down but whether we can meet the rapidly developing aspirations of highly educated people in tin shacks. To those who dream that, as capitalism develops, it will eradicate slums, Sinclair of Architecture for Humanity says dream on. "You can't fight something that has a stronger model than you [do]. It's never going to happen again. The fact of it is that if you tried to do it in some of these informal settlements, they could take out the city . . . march on the central business district, and it's game over."

Paul Mason reports from Manila on Tuesday 16 August in "Slums 101" (Radio 4, 8pm) and on "Newsnight" (BBC2, 10.30pm).