Back in 1840, two teenage Spaniards, Valentin and Manuel Gavito, set sail for the New World. They stopped first in Cuba, then sailed up the Gulf coast and settled just north of the Rio Grande in Texas, where they became ranchers. Quite which country Texas belonged to then, if any, was an open question. Until 1836, when it declared itself an independent republic, it had been part of Mexico. The Mexicans still claimed it. But then came the battle of Palo Alto in May 1846 - the first skirmish in the Mexican-American war. By 1848 the United States had claimed Texas for its own. The Gavito brothers didn't cross the border; the border crossed them.

More than a century and a half later, Jose Gavito, one of Manuel's direct descendants, describes himself as "Texican". His pioneering forebears settled in what later became Brownsville. Gavito is still there. The Mexican border is just four blocks away from his desk in the heritage centre. It is a unique city, he says - bilingual, bicultural, with a bi-heritage. "Every day there are new immigrants coming in. Whether legally or illegally, the flow has never stopped."

But while the people keep coming as ever, the politics of their arrival has changed. This year President Bush stationed 6,000 National Guardsmen along the border and the US Congress vowed to build a 700-mile wall to keep illegal immigrants out. Meanwhile, in spring, the country saw the biggest demonstrations since Vietnam in protest against anti-immigrant legislation many believe could lead to mass deportations. Immigration could well be one of the deciding factors in the midterm elections in two weeks' time.

It took me two weeks to drive the 2,000 miles along the border. My journey began at Brownsville - one of the poorest cities of its size in the country, standing at the mouth of the Rio Grande, at the most south-easterly point of the Mexican-US border - and ends with metal posts running into the Pacific Ocean dividing San Diego from Tijuana. In between come the honky-tonk towns of Texas, the cactus-studded desert of New Mexico and Arizona, and the dunes and mountain passes of California.

Along the way, culture, demography and technology seem to mock the border's presence. In most frontier towns the population is more than 80% Latino. Whether you are in the US or Mexico makes little difference to your cellphone, which will pick up a signal wherever it can find it. Spanish is generally spoken; English is usually understood. Big belt buckles, big hats and cowboy boots are de rigueur on both sides. Economically, however, you are never in any doubt. The border does mark one very clear difference: the average national income is four times higher and the infant mortality rate three times lower on one side than on the other. "It's the most extreme economic precipice on the planet," says author and lecturer Mike Davis, in San Diego.

On any one day some young Americans will cross the border so they can legally drink alcohol and some Mexicans will die of thirst trying to cross it illegally so they can work. Hundreds of thousands of Mexicans and central and South Americans will pay millions of dollars to cross the border at its most porous points. The US government will pay billions of dollars and employ tens of thousands of people to try to stop them. The border may be an economic barrier, but maintaining it is an industry.

In Brownsville, as in the rest of Texas, the border is more of a banal fact of life than elsewhere. However, there are more border patrols around town than there used to be. The days are now gone when you could see people swim under the bridge, under the noses of customs officials, and dump their wet clothes on the bank. But that hasn't stopped the daily human traffic.

Over in Matamoros, across the river from Brownsville, Sandra Duran is one of many with a finger in every pie on both sides of the border. Like many here, she has family on both sides; unlike most, she also has businesses on both sides. She joined us for tequilas at her restaurant in Matamoros; by the time the coffees had arrived, she had gone over to Brownsville to get changed, drop her kids off with her parents, and returned. "These two cities are dependent on each other 100%," she says.

This became clear the next morning at the local CTM (Confederation of Mexican Workers). Around 400 men crammed into the hall, waiting to see if they would be lucky enough to get a job paying 100 pesos a day ($9.15, less than a fifth of pay in the US), working in a US-owned factory or maquiladora. Four days a week it is the same scene - two days for women, two for men. The union functions like a job centre.

Along with 400 others, Alfonso Gonzales, 18, has been waiting since 6.30am. He's been looking for work for two months. Has he thought of trying to cross the border to where the pay is so much better? "No, my family is here and I have no reason to go there. All I want is 700 pesos a week."

At 8am, Javier Ryolla, chair of the CTM's jobs committee, takes his place at his desk at the front of the hall. Behind him is a picture of the Virgin Mary and the Pope, in his hands is the list of the lucky, and ahead of him 400 pairs of eager eyes.

About 10 miles away in an industrial park is Bon Worth International, which manufactures cheap clothes for elderly women and where the lucky ones might be sent. Once based in the Carolinas, it relocated during the 80s, making several hundred redundant. "We came to Mexico for labour savings," explains Franz Evans, the plant's manager, who lives in Brownsville and commutes daily to Matamoros. "In the Carolinas we were paying $12.50 an hour. Down here we pay $2.50 an hour with benefits. There's no way we would have remained in business if we hadn't moved to Mexico," says Evans, who speaks no Spanish. "We'd save a bit more money in the Far East but it's 45 days in shipping to get the finished product back here."

In a cavernous warehouse where the whir of sewing machines echoes like gunfire, rows of Mexican labourers sew together garments which are then ironed and loaded on to trucks. Ten days later, in the border town of Yuma, California, I would visit a Bon Worth store on a strip mall offering "America's best pants" for $9.99.

Nestling on the banks of the Rio Grande 200 miles north-west of Brownsville, just south of Laredo, is the small town of El Cenizo. Just how small is not clear. The census says it is home to 3,545 - the mayor, Raul Reyes, says the population is almost double that. According to the census, the town is 98.9% Hispanic - the mayor thinks it is more like 100%. Its motto is "Two cultures, one great city". El Cenizo is about as poor as it gets on the north of the river. Two-thirds of its families live below the poverty line; the median family income ($13,438 or £7,226) is a fifth of the national average. It started in the early 80s as a colonia - a shantytown built on land for which its owners could find no other use. For a relatively small deposit and regular payments thereafter, people could buy lots and build on them. Paved streets, sewage, electricity and running water would not come until much later, if at all.

Small as it is, El Cenizo made big news seven years ago when the council passed an ordinance declaring that all city meetings would be held in Spanish. The town also passed a Safe Haven ordinance forbidding city employees and officials to cooperate with the border patrol and immigration service in their bid to find undocumented migrants.

Reyes is just 23 and lives with his mum. His family arrived in El Cenizo in 1992 from Corpus Christi, 150 miles to the east. "For $50 down and $100 a month, she could own her own place." They arrived to a concrete slab on the ground and four walls with no roof, and slept five to a bed. "There was running water and electricity in the town," Reyes recalls, "but we didn't have it."

Reyes is not just the first person from his family to go to university; he is the first mayor of El Cenizo to have a degree. The Spanish-speaking ordinance came about, he says, because while some people in the town spoke English, everybody spoke Spanish and they didn't want people to be left out. A year and a half ago, they changed again - to bilingual meetings - but not before a couple of radio shock jocks had told the city commissioner, "If your people cannot understand my language, they should get on their burros and go back to Mexico. You are in America. You got to speak American. You Mexicans have your own country. You know why I don't have to learn to speak Spanish? Because this is goddamn America. Go back to your country."

The town was disinclined to cooperate with the border patrol because residents felt they were harassing them. Border patrol agents would stop school buses and ask everybody for their papers, on one occasion throwing two young men to the ground, handcuffing them and searching them at gunpoint. Another time, 44-year-old Jesus Olivaries, who delivered the Laredo Times after he finished his night shift at the gas station, was stopped by an agent and questioned about his legal status with a gun to his head.

Reyes has big plans for his town and his job. What he calls his "administration" comprises two employees: until recently one was his mother. "We are here to serve the public, and they were treating local people in a disrespectful way," he says. "Most of that behaviour has stopped now. We have a $429,000 annual budget. We don't have the resources to secure the border but we shouldn't be punished for that."

About 10 minutes' walk from Reyes's office flows a stretch of the Rio Grande about 15 metres wide. As I drove down to take a look, a car full of people was leaving in the opposite direction. Alone on the bank was a teenage boy with four tyres and a heap of wet clothes. He wasn't answering any questions, except about fishing, and after a while the car came back empty and picked him up.

At the city of Del Rio, the river starts the first of its elaborate curves before it heads south towards the Chisos Mountains while the main road heads north. A 200-mile detour down back roads hugging the border takes you through towns and hamlets that have occasionally been used for spaghetti western sets. Most look desolate. Then Lajitas, a luxury resort that bills itself as the ultimate hide-out, emerges like a mirage.

At Lajitas the cheapest room in low season goes for $175 a night and the most expensive cottage is $825. For the Texas beau monde there are weekly flights in private jets from Dallas and "Get out of the Dog House" packages for the negligent businessman, which offer prickly pear margaritas and Mexican wedding cookies on your arrival and two 50-minute massages. Behind the hotel complex runs the Rio Grande. On the Mexican side live four extended families; a boat is tied up at the riverside. The nearest official border crossing is in Presidio, 50 miles away. Every day, to avoid the 100-mile round trip, people cross the river by boat in a couple of minutes. You can see their footprints on the Texan side. The afternoon I arrived a man was nipping back to Mexico to repay a debt to a friend. The next day Ms Rodriguez rowed her two children and a rooster over to see their grandmother in Mexico.

Ms Rodriguez was born in Mexico and has a permit to work in the US. Her children are US citizens. In the past, she says, there were 30 families on the Mexican side. When the hotel was in its formative stages (it is still not finished), guests would row across for a cheap meal. But after September 11 the border patrol put a stop to it, forcing people to go via Presidio. "It's Sunday. I'm not going to travel all that way to take my children to see their grandmother."

Ms Rodriguez says she has never seen an illegal immigrant cross at that point. On the other hand, last year 1,160 undocumented workers were found in Big Bend National Park to the east of Lajitas, along with 23,000lb of marijuana.

September 11 transformed the debate about immigration in the US. Before the terrorist attacks, long-standing racist and nativist impulses were allied with concerns about migrant labourers driving down wages. Afterwards, it became a security issue - if poor Mexicans can come in looking for work that easily, then what is to stop terrorists looking for trouble?

"But the terrorists didn't come from the border with Mexico," says Sister Liliane Alam, who runs Las Americas immigrant advocacy project in El Paso. "They were documented. They came through very easily because they came from countries that are friends with America."

My arrival in El Paso, a couple of hundred miles upstream from Presidio, coincided with that of Wisconsin Republican congressman James Sensenbrenner. He was in El Paso to hold a town hall meeting to discuss the immigration bill he introduced last year which prompted the huge protests and, eventually, goaded Bush's response. His bill calls for hundreds of miles of fencing to be built at the points where most illegal border crossings take place; it would make assisting illegal immigrants a felony and force employers to check the legal status of all employees. Opponents of the bill branded it the most draconian immigration law in history, arguing that it was unworkable and penalised the more than 11 million illegal residents already in the country. Its supporters claimed it was vital to national security, protecting domestic workers' rights and enforcing existing laws.

The issue was a thorny one for the Bush administration, dividing the key elements of the coalition it brought together to win the election in 2004. Big business welcomed immigration for low-paid jobs; xenophobes and racists loathed it. Moreover, Bush had won between 40% and 45% of the Hispanic vote nationwide - a sizeable minority that was key to his victory in the swing states of Arizona, Nevada, New Mexico and Florida.

In northern California this year, tons of pears rotted because the seasonal migrant labour did not show up. Those who used to travel up from Mexico illegally were less likely to come and more likely to get caught if they tried. Last month more than 300 fruit growers from every agricultural state in the country protested on Capitol Hill, demanding a guest-worker agricultural programme.

Sensenbrenner's bill was passed in the House of Representatives last December by 239 to 182, but has not yet been passed by the Senate which introduced a compromise favouring guest-worker programmes and a bid to regularise the situation of the undocumented workers already in the country. Earlier this month, wishing to be seen to be doing something before the elections, the two houses approved the building of the 700-mile wall.

A group called the Minutemen had already been founded, insisting it was their patriotic duty to protect the border themselves in the absence of state intervention. The name came from a militia of the American colonies who vowed to be ready for battle in defence of their nation at a minute's notice.

In May, Bush - who favoured the Senate compromise - announced the deployment of 6,000 National Guardsmen along the border, a 50% increase in border patrol agents, biometric identity cards to make it easier for employers to determine the legal status of an employee, and a guest worker programme for temporary migrants.

Meanwhile, the prospect of the bill becoming law struck fear in the Hispanic community. Back in the 30s, thousands of Latinos, many of them American citizens, were rounded up and forcibly deported to Mexico to protect white people's jobs during the Depression - could it happen again? Millions of Latinos protested in April and May. Half a million came out in Los Angeles and Dallas, 300,000 in Chicago, 200,000 in Washington DC - right down to 3,000 in Garden City, Kansas (population 30,000). Children walked out of school; their parents walked off the job. Numbers were greater than at any anti-war demonstration in the past four years.

In El Paso, the same groups who organised the demos called an alternative meeting to Sensenbrenner's, entitled It's Our Border, Too. Around 75 people showed up on the night of an unforgiving downpour. They complained of random checkpoints erected in colonias where people are stopped "not just based on the colour of their skin but the condition of their cars". Afterwards, Josiah Heyman, a professor of anthropology at the University of Texas at El Paso, who studies the border, spelt out what he regards as the lunacy of Sensenbrenner's approach. "They're burning billions of dollars to catch a guy who wants to mow somebody's lawn."

Armando Alarcon's father was one such guy. Thirty-six years ago he waded across the Rio Grande illegally with his wife, carrying their child in his arms. Armando, now 38, grew up to be a model citizen. He studied engineering at university, fought in the first Gulf war and now earns a good salary as a sales manager for one of the US's largest trucking companies. He was living the dream: married with children, working hard, even learning to fly in his spare time. One day during a flying lesson, something caught his eye. "I could see somebody out there in the desert. Every year I used to hear of people dying out there, then I just saw someone."

The glimpse gave him an idea - to fly up with bottles of water and drop them for people he saw crossing the desert. "I told one or two people and they said I was crazy, so I didn't mention it again." Then, four years ago, the border patrol found the body of an eight-year-old girl who had been abandoned by her smuggler. Alarcon bought a Cessna 172 and founded a group called Paisanos al Rescate - Fellow Countrymen To The Rescue.

In 2004 roughly one person every day died trying to cross the border. Some are murdered by coyotes (people traffickers) but many die of thirst. In the small border town of Holtville, California, in the dirt patch at the back of Terrace Park cemetery lie the remains of scores who died en route. Each grave carries the name John or Jane Doe imprinted on a brick, plastic flowers and the words "No olvidado" - Not forgotten.

As the government has deployed more agents and National Guardsmen at known crossing points, people have started exploring more dangerous routes. Last year, border patrol officers arrested almost 1.2 million people attempting to enter the US, and believe almost 500,000 more evaded capture.

"The majority who die out there are old people and little kids," says Alarcon. "I just don't care really what people say about it or if they don't like it. It's humanitarian work. It's not illegal."

The two-litre bottles have parachutes attached and little diagrams explaining the immigrants' options. If they are in trouble and want to be rescued, they should lie down and the pilot will call the border patrol to come and pick them up; if they don't want to be rescued, they should stand up and wave, and the pilot will drop more water and move on. "Sometimes you see three or four people in one day, sometimes you don't see any," says Alarcon.

One early morning a few days later, Armando Garcia, who helps Alarcon with the project, took me up in the Cessna. Garcia's day job is as a flight attendant for American Airlines and he likes flying, especially if he might do some good at the same time. As we rise into a clear sky, El Paso blends seamlessly into Ciudad Juarez - its Mexican sister. Away from the city, green gives way to bush, then desert pockmarked with shrubs. You can see the border patrol and National Guardsmen keeping watch.

Many of the crossings are made at night, Garcia says. "The people you find are the ones that get left behind." In the early morning light you can make out well-trodden paths. If Garcia sees anyone, he swoops down as low as is safe and makes the drop. But with storm clouds coming in over the enormous crucifix on Mount Cristo Rey, overlooking Juarez, we turn back. There was no one in need this morning. At least not that we saw.

From El Paso the Rio Grande veers north and the border continues its relentless trek west, through the harsher, cactus-studded desert of New Mexico. More than 130 miles from El Paso in the town of Columbus, Quasimodo is also on the lookout for immigrants. Quasimodo is not his real name. He got it by keeping watch for three nights, knee-deep in pigeon droppings, in the belfry of an abandoned church in the nearby town of Hachita. "There's a $20,000 price on my head on the other side," he explains. "We're wanted by the drug cartels."

Quasimodo is a Minuteman. A few days earlier I had spoken to Carmen Mercer, the group's vice president, who "started securing the border with a handful of patriotic Americans" in her home town of Tombstone. She delivered an ear-splitting tirade against the entire American political establishment for failing the country on immigration, then rang me later to say she had forgotten to mention the diseases and drugs Mexicans are bringing into the country. Quasimodo is nothing like Mercer. With his National Rifle Association hat and rakish gait, he looks like a nativist from central casting, but he's a genial 70-year-old with a good sense of humour. He also has a deep fear of Mexican immigrants, the more so since the occasion he went to an abandoned house in town. "I looked around and there were 12 guys just 10 feet away looking at me," he says, meaningfully.

"Did they attack you?" I ask.

"No," he says.

"Did they look as if they might attack you?"

"No."

"Has an illegal immigrant ever attacked you?"

"No. But they could have had my fanny if they wanted it."

So now he carries a .38 pistol with him wherever he goes. "I couldn't hit the broadside of a barn with it but it makes a noise and I hope that's all it ever needs to do."

Quasimodo, whose house sits right on the desert border, goes out looking for evidence of new illegal immigrant trails. Water bottles, sweet wrappers, sanitary towels and footprints are telltale signs, as is a bivouac made from bushes to shelter the migrants from the heat of the day so they can continue their journey at night. These findings are passed on to the other Minutemen who, on certain weekends, sit in the dark at the designated spots, their huge industrial lights turned off, waiting for the migrants to come their way.

Quasimodo describes it like hunting. "You can hear them coming, like a herd of elephants, stomp, stomp, stomp. It really makes the hair stand up on the back of your neck. You wait until they get real close, then switch the lights on. The immigrants drop, like you just shot 'em, and don't move. Then we call the border patrol and they come and pick them up."

The Minutemen don't touch the immigrants, says Quasimodo, and the immigrants don't run or confront the Minutemen. Everybody, it seems, knows their role in this sorry moment.

Quasimodo's rationale is quite straightforward. "If they come into this country illegally, then that means they're committing a crime and that makes them a criminal. People say, 'Well, they are trying to better themselves' but if I wanted to better myself, I could go and rob a bank. Would that be OK?"

Driving out by the border, we can see the National Guard cementing large metal poles in the ground to stop cars coming through. Quasimodo is pleased with their progress. "Most of the fence here was just barbed wire that had been pulled down. It was really just a marker." The poles are a good start, he reckons. "Israel built a fence and it kept them out."

Does he have any sympathy for the migrants?

"I feel sorry for them for two things. Why doesn't the Mexican government do enough to give them jobs, and why doesn't our government work out a programme so they can come over, work, then go home? That would be better than walking through thorns barefoot and getting bitten by rattlesnakes. I blame both governments."

He justifies his ever-present fear with tales of sightings of "illegals"."I can tell an illegal just by looking at them," he says.

"How?" I ask.

"Well, I can tell you're black just by looking at you and you can tell I'm white."

"But you can't tell my immigration status just by looking at me."

"Well, it's like wild dog versus tame dog," he says. "They just don't have the same kind of look."

More than 300 miles away to the west lie two towns, on either side of the border, with the same name - Nogales. On the Mexican side, an American group called No More Deaths waits with cereal bars, bottled water and first-aid kits for deportees. So long as there is no other outstanding warrant for their arrest, anyone who is caught trying to cross the border illegally in the south-west - including those apprehended by Quasimodo - will eventually end up here. They come by the busload, on average 300 a day. The activists give them water and food, and help those whose feet blistered on the failed desert trek. A few return with tales of mistreatment and abuse. But that morning, as the first bus arrives, all but a handful just pick up a bottle of water and keep on walking. Most go right back out to the border and try again. Some have tried more than 20 times.

As I check into a hotel in Tucson, Arizona, scores of National Guardsmen from Kentucky are having a karaoke session. They have been sent down to help police the border; a hotel worker says they have signed up a number of rooms for the next five years. Meanwhile, out in Lincoln Park, in Tucson's eastern suburbs, Randy Graf, would-be senator, is holding a campaign meeting and barbecue. "We're the greatest country in the world," he's telling his supporters, and he adds, "We have to get serious about securing our borders. We can and we will."

When I saw Graf, a former golf professional, in August, he was campaigning in the Republican primary in one of the few swing constituencies in the state, which stretches from Tucson down to the border. The retiring Republican congressman had endorsed Graf's challenger, believing Graf's hard line on immigration (he's a Minuteman) would alienate too many moderates. He won the primary anyway and, to the 60 or so supporters wearing plastic stars-and-stripes hats and flipping burgers, he was right on point. Most were professionals and retirees. Like Le Pen's constituency in France, they are not that part of the population whose livelihoods are most likely to be affected by immigration but those who fear they will be affected next.

But there is one key difference between this movement and anything you would find in Europe, which became evident halfway through the speech, when Graf related how moved he was at a recent swearing-in ceremony to see a young Uzbek woman, who is in the crowd, become an American citizen. The small crowd cheers as he welcomes her to America. For it is a long-standing feature of American attitudes to migrants that even when they are expressing extreme hostility to a certain group of migrants - in this case brown-skinned and illegal - they still pay homage to the concept of immigration. In 1886, the year the Statue of Liberty was dedicated as the beacon of the tired, the poor, the huddled masses "yearning to breathe free", a mob in Seattle chased most of the Chinese labourers out of the city. When the meeting is over one couple, who are both Minutemen, boast to me of their English heritage.

Ultimately, Graf says, the question of what will happen to the 11 million or so undocumented workers still in the country will resolve itself. "We don't need to deport them," he explains. "All we have to do is enforce our employment laws and pretty soon they won't be able to get a job and will self-deport." This, it seems, is the strategy of the anti-immigration campaigners. Make life so miserable for illegal immigrants that they will leave of their own accord.

Democrats believe having Graf as their opponent will make it easier for them to win back the constituency. But their confidence may be premature. It is not yet clear how the immigration issue will play next month and campaigners for immigrant rights are not confident. "We marched in millions," says Isabel Garcia, head of Derechos Humanos, "but does that necessarily translate into votes? Not really. We are trying, but they have fear and ignorance on their side - and with that you can achieve a lot."

On Garcia's desk is a postcard of Native Americans with the message: "Homeland security: Fighting terrorism since 1692." She talks like a steam train, fuelled by passion, purpose and a little hyperbole. "It's hard to be optimistic right now, but we're fighting. We're fighting for our lives. We're at a real juncture in our country. We're creating a legal apparatus to legitimise abuse, discrimination, even death."

From Tucson to San Diego, the road swings through barren desert and rocky mountain passes. With a population of around 1.2 million, San Diego is the only real city on the border (El Paso, the next biggest, is less than half its size) and the only border city that is wealthier than the nation at large. The binary blend of Mexican-American culture that has endured thus far gives way to a more disparate grab bag of ethnicities, including Asians and African Americans.

Down by the border, the now-famous road sign of a family of three running, designed to warn motorists of immigrants crossing the road, still stands. On the Mexican side, in Colonia Libertad, the border runs right alongside houses perched in tiers like a precarious layered cake. So close you could jump out of a window and land in the developed world.

From Libertad you can see cranes building more walls and higher fences. Driving in the hills on the American side, you find yourself traced by helicopters carving inquiring circles in the sky.

By Border Field State Park stands a large boulder stating "Boundary of the United States, October 1849". At the end of the US-Mexican war in 1848, this stone marked the westernmost border between the two countries - a line in the sand. Back in the 1970s, this was called Friendship Park and was built to symbolise friendship between Americans and Mexicans. Nowadays, at the weekends, families who have been separated by the border come to reunite, each on their own side of the line.

Imperial Beach is empty on the American side, under constant observation by the border patrol, with helicopters buzzing overhead: on the Mexican side it is full of sunbathers, and families having picnics and buying ice creams. Down by the sea children poke their noses through the poles, into a world they are forbidden to enter.

Maria DelaPaz, 36, stands alongside her children, looking through the poles as though in an open prison. She has never been to the US. A welder by trade, she would like to come over and work. "I think this border is racist and inhumane," she says. "People should be free to travel wherever they like. I don't just want to work. I want to see what it's like. I don't believe everything I see on TV. I've only seen Disneyland on TV. That's what my children watch. But I don't think it's all like that over there."

Just a few feet away, the water runs free from one side to the other. But the people stay put.