Congress yesterday passed the first comprehensive revision of legal immigration laws in 66 years, expanding the number of persons allowed to enter the United States by nearly 40 percent and changing the mix of their skills and ethnic backgrounds.

When the legislation goes into effect in 1992, it will more than double the number of immigrants allowed entry because of their job skills, grant temporary "safe haven" to Salvadoran refugees and open the borders to tens of thousands of immigrants from Ireland and other countries who have been largely excluded under current laws.

It also wipes from the statute books decades-old restrictions barring entry to persons on the basis of their beliefs or homosexuality.

"We are achieving two long-sought goals, to make our immigration laws fairer and to use them to serve the nation's economic interest," said Sen. Edward M. Kennedy (D-Mass.), a prime sponsor of the bill.

White House spokeswoman Alixe Glen said the Bush administration strongly supports the legislation.

The measure was approved by the Senate 89 to 8 Friday night but was nearly killed in the House after Hispanic lawmakers organized opposition to a provision they believed could lead to creation of a national identity card.

The opponents, led by Rep. Edward R. Roybal (D-Calif.), succeeded in keeping the legislation from reaching the floor on a procedural vote.

Early Saturday morning, House leaders and Senate sponsors agreed to revive the measure without the controversial provision that would have established a pilot program in which states could have required additional documentation and screening in issuing driver's licenses.

The Senate approved the amended version yesterday by voice vote and the House adopted the new language 264 to 118.

The measure, laden with scores of provisions on a range of immigration issues, is expected to affect hundreds of thousands of people, from Central American refugees in this country who no longer will be under threat of deportation to highly skilled Western European professionals whose chances of coming here are now greatly enhanced.

The legislation will reduce the waiting period -- as much as 10 years in some cases -- for the relatives of permanent residents from Mexico and other countries with a "high demand" for U.S. visas.

And it shifts from Congress to the administration the responsibility for determining whether persons with AIDS or the HIV virus can enter the country, a point of bitter contention in recent years.

The bill's supporters praised its passage as confirmation of the nation's historic open-door policies and a rejection of restrictive policies that in some cases dated to the McCarran-Walter Act of 1952 and have kept celebrated authors, leftist political figures and others from entering the United States because of their ideology or homosexuality.

"Votes in both the House and Senate shattered the myth that Congress is unwilling to adopt fair, humane, generous immigration policies," said Raul Yzaguirre, president of the National Council of La Raza, a Hispanic civil rights organization.

Still in question is whether the Bush administration will remove AIDS and HIV infection from the list of diseases for which a person can be barred from entry or restricted.

Health and Human Services Secretary Louis W. Sullivan has said through a spokesman that he will withhold a decision until he has studied the legislation.

"It would be an incredible injustice to keep {AIDS and HIV infection} on the list," said Robert Bray, spokesman for the National Gay & Lesbian Task Force. "It is up to the White House. The whole world is watching."

The centerpiece of the new law is its revision of numerical caps, including the overall ceiling on the number of visas granted each year for entry into the United States. That number will increase to 700,000 through 1994, and then drop to 675,000. Currently, about 500,000 visas are issued each year.

The number of visas for persons from "traditional source" countries such as Italy, Poland and Ireland will increase to 40,000 annually.

That cap, which will rise to 55,000 in 1995, is designed to broaden the diversity of the immigrant pool by setting aside visas for countries that have been hurt by current laws, which give preference to families of recent immigrants, most of whom come from Latin American and Asian nations.

The law also broadens the mix of immigrants by more than doubling -- from 54,000 to 140,000 annually -- the number of visas granted to persons on the basis of their occupational skills.

More than half of the visas -- 465,000 through 1994 and 480,000 beginning in 1995 -- are set aside for the families of U.S. citizens and permanent residents.

The legislation appeared hopelessly stalled in recent weeks when Sen. Alan K. Simpson (R-Wyo.) won approval of the controversial driver's license program that nearly proved fatal in the House.

Simpson was a prime author of the 1986 revision of laws governing illegal immigration under which 1.7 million undocumented aliens were granted amnesty. The first and last major revision of laws governing legal immigration was in 1924, when the government first set country-by-country quotas. In 1965, those quotas were abolished and the current system giving preference to family unification was established.