The sun is setting and its dying rays cast triangles of light on to the bodies of the Indian workers. Two are washing themselves, scooping water from tubs in a small yard next to the labour camp's toilets. Others queue for their turn. One man stands stamping his feet in a bucket, turned into a human washing machine. The heat is suffocating and the sandy wind whips our faces. The sprinkles of water from men drying their clothes fall like welcome summer rain.

All around, a city of labour camps stretches out in the middle of the Arabian desert, a jumble of low, concrete barracks, corrugated iron, chicken-mesh walls, barbed wire, scrap metal, empty paint cans, rusted machinery and thousands of men with tired and gloomy faces.

I have left Dubai's spiralling towers, man-made islands and mega-malls behind and driven through the desert to the outskirts of the neighbouring city of Abu Dhabi. Turn right before the Zaha Hadid bridge, and a few hundred metres takes you to the heart of Mousafah, a ghetto-like neighbourhood of camps hidden away from the eyes of tourists. It is just one of many areas around the Gulf set aside for an army of labourers building the icons of architecture that are mushrooming all over the region.

Behind the showers, in a yard paved with metal sheets, a line of men stands silently in front of grease-blackened pans, preparing their dinner. Sweat rolls down their heads and necks, their soaked shirts stuck to their backs. A heavy smell of spices and body odour fills the air.

Next to a heap of rubbish, a man holds a plate containing his meal: a few chillies, an onion and three tomatoes, to be fried with spices and eaten with a piece of bread.

In a neighbouring camp, a group of Pakistani workers from north and south Waziristan sit exhaustedly sipping tea while one of them cooks outside. In the middle of the cramped room in which 10 men sleep, one worker in a filthy robe sits on the floor grinding garlic and onions with a mortar and pestle while staring into the void.

Hamidullah, a thin Afghan from Maydan, a village on the outskirts of Kabul, tells me: "I spent five years in Iran and one year here, and one year here feels like 10 years. When I left Afghanistan I thought I would be back in a few months, but now I don't know when I will be back." Another worker on a bunk bed next to him adds: "He called his home yesterday and they told him that three people from his village were killed in fighting. This is why we are here."

Hamidullah earns around 450 dirhams (£70) a month as a construction worker.

How is life, I ask.

"What life? We have no life here. We are prisoners. We wake up at five, arrive to work at seven and are back at the camp at nine in the evening, day in and day out."

Outside in the yard, another man sits on a chair made of salvaged wood, in front of a broken mirror, a plastic sheet wrapped around his neck, while the camp barber trims his thick beard. Despite the air of misery, tonight is a night of celebration. One of the men is back from a two-week break in his home village in Pakistan, bringing with him a big sack of rice, and is cooking pilau rice with meat. Rice is affordable at weekends only: already wretched incomes have been eroded by the weak dollar and rising food prices. "Life is worse now," one worker told me. "Before, we could get by on 140 dirhams [£22] a month; now we need 320 to 350."

The dozen or so men sit on newspapers advertising luxury watches, mobile phones and high-rise towers. When three plastic trays arrive, filled with yellowish rice and tiny cubes of meat, each offers the rare shreds of meat to his neighbours.

All of these men are part of a huge scam that is helping the construction boom in the Gulf. Like hundreds of thousands of migrant workers, they each paid more than £1,000 to employment agents in India and Pakistan. They were promised double the wages they are actually getting, plus plane tickets to visit their families once a year, but none of the men in the room had actually read their contract. Only two of them knew how to read.

"They lied to us," a worker with a long beard says. "They told us lies to bring us here. Some of us sold their land; others took big loans to come and work here."

Once they arrive in the United Arab Emirates, migrant workers are treated little better than cattle, with no access to healthcare and many other basic rights. The company that sponsors them holds on to their passports - and often a month or two of their wages to make sure that they keep working. And for this some will earn just 400 dirhams (£62) a month.

A group of construction engineers told me, with no apparent shame, that if a worker becomes too ill to work he will be sent home after a few days. "They are the cheapest commodity here. Steel, concrete, everything is up, but workers are the same."

As they eat, the men talk more about their lives. "My shift is eight hours and two overtime, but in reality we work 18 hours," one says. "The supervisors treat us like animals. I don't know if the owners [of the company] know."

"There is no war, and the police treat us well," another chips in, "but the salary is not good."

"That man hasn't been home for four years," says Ahmad, the chef for the night, pointing at a well-built young man. "He has no money to pay for the flight."

A steel worker says he doesn't know who is supposed to pay for his ticket back home. At the recruiting agency they told him it would be the construction company - but he didn't get anything in writing.

One experienced worker with spectacles and a prayer cap on his head tells me that things are much better than they used to be. Five years ago, when he first came, the company gave him nothing. There was no air conditioning in the room and sometimes no electricity. "Now, they give AC to each room and a mattress for each worker."

Immigrant workers have no right to form unions, but that didn't stop strikes and riots spreading across the region recently - something unheard of few years ago. Elsewhere in Mousafah, I encounter one of the very few illegal unions, where workers have established a form of underground insurance scheme, based on the tribal structure back home. "When we come here," one member of the scheme tells me, "we register with our tribal elders, and when one of us is injured and is sent home, or dies, the elders collect 30 dirhams from each of us and send the money home to his family."

In a way, the men at Mousafah are the lucky ones. Down in the Diera quarter of old Dubai, where many of the city's illegal workers live, 20 men are often crammed into one small room.

UN agencies estimate that there are up to 300,000 illegal workers in the emirates.

On another hot evening, hundreds of men congregate in filthy alleyways at the end of a day's work, sipping tea and sitting on broken chairs. One man rests his back on the handles of his pushcart, silently eating his dinner next to a huge pile of garbage.

In one of the houses, a man is hanging his laundry over the kitchen sink, a reeking smell coming from a nearby toilet. Next door, men lie on the floor. They tell me they are all illegal and they are scared and that I have to leave.

Outside, a fistfight breaks out between Pakistani workers and Sri Lankans.

The alleyways are dotted with sweatshops, where Indian men stay until late at night, bending over small tables sewing on beads.

A couple of miles away, the slave market becomes more ugly. Outside a glitzy hotel, with a marble and glass facade, dozens of prostitutes congregate according to their ethnic groups: Asians to the right, next to them Africans, and, on the left, blondes from the former Soviet Union. There are some Arab women. Iranians, I am told, are in great demand. They charge much higher prices and are found only in luxury hotels.

Like the rest of the Gulf region, Dubai and Abu Dhabi are being built by expat workers. They are strictly segregated, and a hierarchy worthy of previous centuries prevails.

At the top, floating around in their black or white robes, are the locals with their oil money. Immaculate and pampered, they own everything. Outside the "free zones", where the rules are looser, no one can start a business in the UAE without a partner from the emirates, who often does nothing apart from lending his name. No one can get a work permit without a local sponsor.

Under the locals come the western foreigners, the experts and advisers, making double the salaries they make back home, all tax free. Beneath them are the Arabs - Lebanese and Palestinians, Egyptians and Syrians. What unites these groups is a mixture of pretension and racism.

"Unrealistic things happen to your mind when you come here," a Lebanese woman who frequently visits Dubai tells me as she drives her new black SUV. "Suddenly, you can make $5,000 [£2,800] a month. You can get credit so easy, you buy the car of your dreams, you shop and you think it's a great bargain; when you go to dinner, you go to a hotel ... nowhere else can you live like this."

Down at the base of the pyramid are the labourers, waiters, hotel employees and unskilled workers from India, Pakistan, Sri Lanka, Ethiopia, the Philippines and beyond. They move deferentially around the huge malls, cafes, bars and restaurants, bowing down and calling people sir and madam. In the middle of the day, during the hottest hours, you can see them sleeping in public gardens under trees, or on the marble floors of the Dubai Mosque, on benches or pieces of cardboard on side streets. These are the victims of the racism that is not only flourishing in the UAE but is increasingly being exported to the rest of the Middle East. Sometimes it reminds you of the American south in the 1930s.

One evening in Abu Dhabi, I have dinner with my friend Ali, a charming Iraqi engineer whom I have known for two decades. After the meal, as his wife serves saffron-flavoured tea, he pushes back his chair and lights a cigar. We talk about stock markets, investment and the Middle East, and then the issue of race comes up.

"We will never use the new metro if it's not segregated," he tells me, referring to the state-of-the-art underground system being built in neighbouring Dubai. "We will never sit next to Indians and Pakistanis with their smell," his wife explains.

Not for the first time, I am told that while the immigrant workers are living in appalling conditions, they would be even worse off back home - as if poverty in one place can justify exploitation in the other.

"We need slaves," my friend says. "We need slaves to build monuments. Look who built the pyramids - they were slaves."

Sharla Musabih, a human rights campaigner who runs the City of Hope shelter for abused women, is familiar with such sentiments. "Once you get rich on the back of the poor," she says, "it's not easy to let go of that lifestyle. They are devaluing human beings," she says. "The workers might eat once a day back home, but they have their family around them, they have respect. They are not asking for a room in a hotel - all they are asking for is respect for their humanity."

Towards the end of another day, on a fabulous sandy beach near the Dubai marina, the waves wash calmly over the beautiful sand. A couple are paragliding over the blue sea; on the new islands, gigantic concrete structures stand like spaceships. As tourists laze on the beach, Filipino, Indian and Pakistani workers, stand silently watching from a dune, cut off from the holidaymakers by an invisible wall.

Behind them rise more brand-new towers.

"It's a Green Zone mentality," a young Arab working in IT tells me. "People come to make money. They live in bubbles. They all want to make as much money as possible and leave."

Back at the Mousafah camps, a Pakistani worker walks me through his neighbourhood. On both sides of the dusty lane stand concrete barracks and the familiar detritus: raw sewage, garbage, scrap metal. A man washes his car, and in a cage chickens flutter up and down.

We enter one of the rooms, flip-flops piled by the door.

Inside, a steelworker gets a pile of papers from a plastic envelope and shoves them into my lap. He is suing the company that employed him for unpaid wages. "I've been going to court for three months, and every time I go they tell me to come in two weeks." His friends nod their heads. "Last time the [company] lawyer told me, 'I am in the law here - you will not get anything."

Economically, Dubai has progressed a lot in the past 10 years, but socially it has stayed behind," says Musabih. "Labour conditions are like America in the 19th century - but that's not acceptable in the 21st century."