The United States has an estimated 12 million illegal immigrants, a record number. Its last mass amnesty program, which began in 1987, legalized 2.7 million. President Bush proposed an immigration plan that would give some workers a path to legalization. But it died last year under assault from people who said it would lead to more illegal immigration.

Europe has held at least 20 legalizations in the past 25 years, giving residency papers to about four million people. Italy and Spain account for about two-thirds of the total, to the consternation of northern Europeans who see the south as the Continent’s weak back door. With free movement across much of Europe, legalized immigrants can easily head north, alarming those worried about job competition, welfare costs, cultural clashes or terrorist threats.

Southern Europe’s tolerance for illegal immigration has several explanations. Its aging populations and booming economies created a need for foreign workers. Its proximity to northern Africa and eastern Europe places it close to countries that supply them. And its economies have traditionally depended more on off-the-books workers.

No country has run more legalization programs than Spain, which has carried out six since 1985. As recently as a decade ago, immigrants made up less than 2 percent of the population. Now they are more than 10 percent. About 40 percent come from eastern and northern Europe; 38 percent come from Latin America; and 20 percent from Africa.

Despite the rapid change, until recently there was little political conflict, with legalizations occurring under both conservative and socialist governments. Spain even offers immigrants free health insurance, whether they are legal or not.

“The attitude toward unauthorized migrants is much more relaxed than in the United States,” said Joaquín Arango, a sociologist at Complutense University in Madrid.

The acceptance has been attributed to newfound prosperity, the need for workers, the progressive culture of post-Franco Spain and the shared language with Latin Americans, which spares Spain a major source of tension in the United States.