FEW American neighbourhoods are so exuberantly Mexican as Boyle Heights in east Los Angeles. Paintings of the Virgin Mary adorn walls around César Chávez Avenue. Local shops advertise productos oaxaqueños. Immigrants from south of the border, particularly the kind who carry dodgy Social Security cards, still fetch up in the area. But not as often as they did, according to Nativo Lopez, a Hispanic political activist who keeps an office in Boyle Heights. “This is no longer the west coast Ellis Island,” he says.

Just under 1m illegal immigrants are thought to live in Los Angeles County. That is twice as many as in any other American metropolis. Yet the number may have peaked. This month the Urban Institute, a think-tank, estimated that the county lost some 15,000 illicit residents between 2002 and 2004. In the same period America as a whole added more than 1m. Los Angeles's illegal immigrants are relatively old (only 42% are under 30, compared with 49% nationwide) and more likely to have American children. That suggests many will soon become citizens.

There are two reasons for this change. The first is that people who steal across the border or quietly outstay their visas now avoid Los Angeles, just as they increasingly bypass other traditional gateways such as New York and Chicago. The number of immigrants, both legal and illegal, arriving in Los Angeles has fallen since 1990 (see chart). In that year one out of every six recent immigrants lived in the metropolis. By 2005 the proportion was one in 14.

Increasingly, Mexican immigrants instead head to midwestern and southern states such as Ohio, Georgia and Texas. Construction sites and meat-packing plants there used to recruit many Hispanic labourers from California and other American states, says Jeffrey Passel, a demographer at the Pew Hispanic Centre. Now they are more likely to draw people from south of the border. Few people associate Dallas with illegal immigrants, but the Texas city has more of them as a proportion of its population than does Los Angeles.

The second reason why the number of illegal immigrants in Los Angeles has levelled off is that many are leaving the city. Emilio Amaya, who counsels unauthorised immigrants in San Bernardino, 55 miles (90km) east of downtown Los Angeles, says that between two- and three-tenths of his clients report that they moved there from the city. San Bernardino is currently 56% Hispanic, and growing.

The migrants are lured partly by a boom in unskilled jobs. San Bernardino and Riverside Counties process much of the cargo that arrives in the ports of Los Angeles and Long Beach. As trade with China increases, so does the need for huge warehouses—one, currently under construction, is the size of eight Manhattan city blocks—and workers to build and toil in them. These two dusty, sprawling counties, together known as the Inland Empire, are doing something that is almost unheard of in America these days: creating manufacturing jobs.

There are other good reasons to leave Los Angeles. Maria, who moved out before she became a permanent resident and is now studying for a citizenship test in a San Bernardino shopping mall, provides three. Housing is much cheaper there than in Los Angeles, she says. The schools are better. And local gangs, although they are growing, are not nearly as entrenched as they are in the big city.

In short, illegal immigrants are leaving Los Angeles for the same reasons most people do. The difference is that their new neighbours are unlikely to welcome them with open arms. Several towns in the Inland Empire have passed resolutions against illegal immigrants and the companies that hire them. Wehirealiens.com, a website that collects allegations against employers, was founded by a software developer in Riverside County. By following jobs from cities to suburbs and small towns, illegal immigrants often move from staunchly Democratic districts to strongly Republican ones.

Rob Paral, a researcher, has used census returns to estimate the numbers of illegal immigrants who were living in various congressional districts in 2005. His work supports the argument, often made by proponents of more liberal immigration laws, that illicit workers tend to reside in Democratic areas. But it also shows that this pattern is changing fast. Between 2000 and 2005 the number of illegal immigrants in California's Democratic districts grew by 8%. In Republican areas the illegal population swelled by 36%.

The same trend is evident elsewhere. The 15th congressional district in Harlem, one of the most invincibly Democratic places in New York or anywhere else, seems to have shed illegals. So has the district on the northern edge of Chicago that elected Rahm Emanuel, a powerful Democrat. Meanwhile, the number of illegal immigrants went up by 50% in the mostly suburban Illinois constituency of Dennis Hastert, the former Republican speaker of the House of Representatives. Indeed, across America, where comparisons are possible, Democratic districts added undocumented residents at half the rate of Republican ones. That helps to explain why Republican candidates talked so much about illegal immigration before last year's mid-term elections.

In some ways, the disappearance of illegal immigrants is good news for Los Angeles. It takes pressure off public services: the proportion of schoolchildren who are classified as “English learners”, for example, has fallen from a peak of 47% in the mid-1990s to 41% today. And it makes it easier for the city's large Hispanic population to rise into the middle class. As a group, Hispanics had been weighed down by poorly educated new arrivals.

Yet the fact that people are being drawn away from places like Los Angeles is worrying, too. Illegal immigrants are the canaries in the economic coal mine, sensitive to the slightest changes in the job market. Their presence in a city may cause problems, but their departure suggests that a place is losing some of its economic dynamism. After all, most cities, if they could choose, would rather have San Bernardino's problems than Harlem's.