Of all the economic dynamics buffeting the American middle class, immigration might seem the easiest to explain: as millions of poor immigrants from Latin America poured illegally into the country seeking work, the conventional wisdom goes, they competed with more expensive American workers, displacing them from their jobs and undercutting their wages.

A closer look at big issues facing the country in the 2012 Election.

This understanding of immigration helped propel a vast increase in the Border Patrol’s budget over the last two decades to stop immigrants on their way in. It was the rationale for proposals to build a long, tall fence along the southern border. President Obama, who in 2008 said he would push for a law that would grant many of these immigrants legal access to jobs in the United States, instead deported a record number of immigrants working here illegally.

But this explanation of the impact of immigration is mostly wrong.

For years, economists have been poring through job market statistics looking for evidence that immigrants undercut less-educated Americans in the labor market. The most recent empirical studies conclude that the impact is slight: they confirm earlier findings that immigration on the whole has not led to fewer jobs for American workers. More significantly, they suggest that immigrants have had, at most, a small negative impact on the wages of Americans who compete with them most directly, those with a high school degree or less.

Meanwhile, the research has found that immigrants – including the poor, uneducated ones coming from south of the border — have a big positive impact on the economy over the long run, bolstering the profitability of American firms, reducing the prices of some products and services by providing employers with a new labor source and creating more opportunities for investment and jobs. Giovanni Peri, an economist at the University of California at Davis, estimated that the wave of immigrants that entered the United States from 1990 to 2007 increased national income per worker by about $5,400 a year on average, in 2007 dollars. He also concluded that the wave had a small positive impact on the average wage of American workers, by lifting the overall economy. If immigrants hurt anyone, it was the previous cohort of immigrants, with whom they most directly compete in the labor market.

These conclusions may seem to fly in the face of the laws of supply and demand. But they are not quite so odd. They can become obvious, in fact, once we take into account the response of American companies, and workers, to the inflows of cheap foreign labor.

The belief that immigration would simply displace American workers relies on the assumption that employers would do nothing but replace their costly domestic labor force with cheap imports. But that’s not typically what happens. For one thing, immigrants and domestic workers are not identical. Even the least-educated Americans are likely to be more fluent in English — better at talking with bosses or communicating with customers. When a contractor in Fresno expands into roofing, it will not just need a bunch of cheap immigrant roofers. It will also need an American supervisor and maybe an extra clerk.

Faced with a new, different pool of workers, companies often invest to reap the higher profits that the labor allows. Contractors, for instance, will be able to take on projects that would not have been profitable paying higher wages to domestic workers – like the roofing example in Fresno. This provides new opportunities for immigrants and for more highly paid domestic workers alike.

Mr. Peri and Chad Sparber of Colgate University found that American workers in states with large shares of less-educated immigrants gravitate toward occupations like cashiers and bank tellers, waiters or sales floor clerks, which require more communications skills. Foreigners, in turn, stick to manual tasks and physical labor. By encouraging this specialization and capital investment, immigration contributes to productivity growth.

In other words, immigration can produce domestic jobs. Restaurants are much less common in Norway than the United States because Norway lacks the cheap labor — making a dinner out in Oslo prohibitively expensive. In many New York restaurants, the American waiters and hosts owe their jobs to the underpaid illegal immigrants in the kitchen, whose low wages allow the restaurant to exist. The vast agricultural industry in the Central Valley of California might not exist without cheap immigrant farm workers who make it profitable.

There are victims of immigration. Immigrants can displace domestic workers – before business investment starts rising and creating new jobs. This is particularly notable in economic downturns, when demand and business investment are depressed. Some displaced workers may not be able to fit in the reconfigured labor market, even if new investments kick in and the economy as a whole benefits. A 50-year-old American janitor with no high school degree may find it hard to make the transition to another job when immigrants move into the building maintenance business.

This dynamic potentially causes a small negative impact on the wages of less-skilled workers – but it’s also possible that this impact is positive. A study by Mr. Peri and Gianmarco Ottaviano of Bocconi University in Milan concluded that the immigration wave into the United States from 1990 to 2006 changed the wages of American workers with no high school degree by somewhere from minus 0.1 percent to plus 0.6 percent.

But over the long term, most less-skilled American workers are likely to benefit. Immigrant workers, in fact, may help their American peers resist the forces of globalization and technological progress that have been walloping the American middle class.

Those nostalgic for strawberry fields harvested by well-paid Americans ignore the fact that without the cheap foreigners, there might not be American strawberry fields. Chances are, it would be cheaper to import the strawberries. When the bracero program ended in the 1960s, tomato growers in California responded to the sudden shortage of Mexican immigrant farm workers by deploying a new mechanical harvester and a tomato that could be cut by machine.

These days, the problem of low-wage immigration seems academic. Since the financial crisis in 2009, poor immigrants from Latin America have been mostly leaving the United States, unable to find a decent job here. American workers might want them back. “If some firms don’t expand because this labor isn’t there,” Mr. Peri says, “they will create less jobs for native workers.”