WASHINGTON - The House approved far-reaching assistance on Wednesday for the housing market, including an aggressive plan to help hundreds of thousands of borrowers avoid foreclosure. The measure also includes broad authority for the Treasury Department to protect the nation's two largest mortgage finance companies from collapse.

The White House, citing an urgent need to restore market confidence in the two mortgage giants, Fannie Mae and Freddie Mac, said President Bush would sign the measure despite his opposition to the inclusion of $4 billion in grants for local governments to buy and refurbish foreclosed properties.

Bush's support ensures that the bill will become law after final passage by the Senate, possibly on Friday or Saturday. The House approved the bill by a vote of 272-152, with just 45 Republicans joining 227 Democrats in favor of it.

Lawmakers described the legislation as a landmark shift in the government's role in the housing market.

Lawmakers said the bill, which seeks to slow the steepest slide in house prices in a generation, extends a generous helping hand both to Wall Street and Main Street. They said it would rank in importance with the creation of the Home Owners' Loan Corp. as part of the New Deal to prevent foreclosures in the 1930s and the legislation in 1989 responding to the savings and loan crisis.

Rep. Barney Frank, D-Mass., a primary author of the legislation, said troubled homeowners might get relief within days of Bush signing the bill, because lenders have long known details of the legislation and could move quickly to help borrowers refinance.

However, the vote laid bare divisions within Republican ranks as its members came under pressure from the White House and business groups to support the measure but also expressed concern about its potential cost to taxpayers.

House Minority Leader John Boehner, R-Ohio, expressed disappointment that the president would sign "multibillion-dollar bailout for scam artists and speculative lenders."

Rep. Sam Johnson, R-Texas, echoed that sentiment, saying: "Just because the housing market has tumbled doesn't mean we should capriciously finance a big, fat government bailout."

The legislation, much of which has been debated and fretted over on Capitol Hill for months, leaves numerous questions unanswered. The biggest unknown is whether the measure will be adequate to slow the downward spiral of home prices and help the economy recover from what many analysts now expect to be a prolonged slowdown.

Perhaps most significantly, the legislation hardens the government's long-implicit assurance that it would step in to rescue the two mortgage giants who together own or guarantee about $5.2 trillion of the nation's $12 trillion in mortgages. Currently, Fannie Mae and Freddie Mac guarantee financing for about 80 percent of new mortgages.

To accommodate a potential rescue for Fannie Mae and Freddie Mac, the bill raises the national debt limit to $10.6 trillion, an increase of $800 billion. The Treasury Department has said it hopes never to use the authority to spend unlimited taxpayer funds -- perhaps hundreds of billions of dollars -- to maintain the solvency of the mortgage giants because they are in sound financial condition. Still, shares in the two companies rose sharply Wednesday in a sign of the market's positive view of having a federal rescue plan in place.

The budget office said the chances were better than even that a rescue would not be needed before the Treasury Department's authority to orchestrate a bailout ends at the end of 2009.

In addition to propping up Fannie Mae and Freddie Mac and helping homeowners avoid foreclosure, the bill creates a permanent affordable housing trust fund that will initially help pay for the mortgage refinancing plan and eventually sponsor the creation of rental housing for Americans too poor to buy homes.

The new regulator will have the authority to increase the capital requirements, the amount of money that companies must maintain to insulate against losses, and will also have authority over executive pay at the two mortgage giants.