The recession and beefed-up enforcement have temporarily slowed illegal immigration, but the problem is far from fixed.

As President Obama and congressional leaders prepare to tackle immigration once again, they should learn from the past and create a system that accommodates the future needs of a recovering economy.

Even with fewer immigrants entering the country illegally, the number already here remains at nearly 12 million. One in 20 workers is here without authorization.

When the economy begins to grow, that number will inevitably climb again despite our best efforts to enforce the current, broken system. Underlying forces in our economy are simply too strong to be thwarted by piecemeal federal efforts.

In nonrecession years, the U.S. economy creates hundreds of thousands of jobs each year that require minimal training or skills. We all know where those jobs can be found: retail, gardening, food preparation and service, home and commercial cleaning. The Labor Department projects that 2.9 million such jobs will be added in the next decade.

At the same time, the pool of native-born Americans that has traditionally filled those jobs continues to shrink.

In the past decade, the number of adults 25 and older without a high school diploma — the type of workers who have fill those lower-skilled jobs — fell by 3.2 million. Their ranks are projected to fall by 2 million to 3 million in the next decade. The number of workers ages 16 to 24, another source of low-skilled labor, will drop by 1.5 million.

Yet our current immigration system offers no legal path for anywhere near a sufficient number of immigrants to enter our country to fill those jobs even temporarily. So they enter illegally, by sneaking across our 2,000-mile border with Mexico or entering legally and then overstaying.

A temporary worker program has been the missing ingredient in the two-decade effort to curb illegal immigration.

The 1986 Immigration Reform and Control Act legalized 2.7 million illegal immigrants and expanded enforcement, but it did nothing to legalize future flow of workers for an expanding economy. The result was predictable failure.

In the early 1950s, Congress and President Eisenhower faced a similar challenge. The U.S. Border Patrol was making 1 million apprehensions a year. Congress and the president responded with more vigorous enforcement, but also a large increase in visas for temporary workers.

The result: Apprehensions at the border fell by 95%. Given the choice, low-skilled immigrants from Mexico chose by the millions to enter legally rather than illegally.

The challenge for Obama and Congress when they take up a new plan is to create a legal alternative to illegal immigration.

To be effective, a temporary visa program must provide a sufficient number of visas to meet long-term structural demand, probably 400,000 or more per year.

The visas must let workers change jobs easily so they can move to sectors where demand is greatest and pay and working conditions competitive.

A new plan must also create a path to legalization for those already in the work force. This need not and should not be amnesty. That much-abused word means getting off scot-free.

In contrast, earned legalization would likely require fines, back taxes, security checks and other requirements such as those contained in bills the Senate considered in 2006 and 2007.

And legalized workers would need to get in line with everybody else should they choose to apply for permanent status.

A temporary worker program would transform the debate about enforcement. If the large majority of people now entering illegally were to enter legally through normal ports of entry, U.S. border agents could focus their time and resources on apprehending real criminals and terrorists.

A sufficient inflow of legal workers would drive out illegal workers, reducing the rationale for workplace raids, national identification cards and employment verification systems. Companies that can hire legal workers would not be so tempted to hire illegal workers.

To overcome political opposition, Democratic leaders must face down labor-union opponents of a temporary worker program, just as Republican leaders seeking a new plan must face down the anti-immigration wing of the conservative movement.

If advocates of responsibility in both parties can work together to enact a sufficiently robust visa program, the president and Congress could finally fix the problem of illegal immigration.