Congress passed and sent to President Reagan a $30.6 billion housing bill before dawn yesterday, and the White House said Reagan is likely to sign it within a few days.

Passage of the two-year authorization measure, the first major housing legislation since 1980, surprised many members of Congress as well as administration officials, who had said they believed that no such bill would reach a vote until next year.

The measure passed the House, 391 to 2, and the Senate by voice vote. The two House members voting against were Philip M. Crane (R-Ill.) and Carl C. Perkins (D-Ky.).

The legislation would provide $15 billion for housing and community development in fiscal 1988 and $15.6 billion in fiscal 1989. It also contains permanent insuring authority for the Federal Housing Administration's home-mortgage insurance program, a provision long sought by the housing and financial industries.

It would provide $7 billion annually for low-income housing assistance, $1.5 billion for public-housing operating subsidies, $2 billion for rural housing, $3 billion for Community Development Block Grants and $225 million for Urban Development Action Grants.

Negotiations on the measure had broken down last week, but last-minute bargaining produced a compromise.

To gain administration approval, funding was scaled back for housing poor people displaced by federally funded development projects and for a controversial home-ownership program for moderate-income families, and some requirements for removal of lead-based paint from federally owned and assisted housing were eliminated.

The bill also would kill a housing-development grant program opposed for years by the White House.

An initial agreement reached last week by congressional conferees was rejected by the Office of Management and Budget, which called the measure a "budget-buster." Backers said the administration "double-counted" some of the spending provisions and misinterpreted other provisions.

"Those who wanted to claim there were big changes" could do so, while supporters of the original bill could say "this is sort of what we wanted, anyway," a Senate staff aide said yesterday.

An administration spokesman called it "a really good bill" that puts a price tag on all of the provisions, rather than authorizing spending "such sums as may be necessary" for some.

The Housing Development Action Grant program is to end with fiscal 1989. The measure would authorize spending $75 million each in fiscal 1988 and 1989, but the appropriations bill contains no money for the program.

A controversial provision requiring moving expenses and rental assistance for 10 years for low- and moderate-income families displaced by two federally funded development projects was cut back. Mayors nationwide had vehemently opposed the original provision, saying that the cost to cities would sharply curtail economic development.

The bill provides aid to poor people displaced by luxury housing development or by commercial and industrial projects that do not principally benefit low- and moderate-income households.

The Nehemiah program to help moderate-income families buy homes would be converted to a two-year experiment, funded at $25 million for fiscal 1988 and $100 million for 1989 and scheduled to end at the end of 1989. An older home-ownership assistance program would be killed.