WASHINGTON (MarketWatch) -- With support from just three Republicans, the Democratic majorities in both the House and the Senate on Friday approved a sprawling, $787 billion economic stimulus package backed by President Barack Obama, handing the new president a major victory on his top economic priority.

The huge package contains billions of dollars in infrastructure spending and assistance to states and the unemployed, and a $400 tax cut for individuals that Obama promoted during his run for the White House. Obama said the tax cuts and spending increases should create or save 3.5 million jobs and help lift the economy from one of the worst recessions in generations.

The version approved by both houses of Congress on Friday is a compromise hammered out after each chamber approved slightly different bills.

Democrats voted overwhelmingly in the House and Senate to back the bill, but no Republicans voted for it in the House and only three voted for it in the Senate. Democratic Sen. Sherrod Brown of Ohio interrupted a visit home for his mother's funeral service and flew back to vote, delaying the final vote until 10:47 p.m., more than five hours after the first senator voted.

Scant Republican support

The House vote was 246 to 183 and the Senate's was 60 to 38. Senate rules required 60 "yes" votes for approval. Ailing Sen. Edward Kennedy, D-Mass., did not vote.

The only Republican senators voting for the bill were Susan Collins and Olympia Snowe of Maine and Arlen Specter of Pennsylvania, who were able to force some changes in the final package. Many Republicans in both chambers fiercely criticized the bill, saying it's full of wasteful spending and won't help the economy.

Republicans offered a plan that was based almost entirely on cutting taxes, but the Democratic majority rejected those ideas.

"This plan was supposed to be about jobs, jobs, jobs, but all it does is spend, spend, spend," said House Republican Leader John Boehner, R-Ohio.

House Speaker Nancy Pelosi, D-Calif., argued exactly the opposite. "This legislation can be summed up in one word: jobs," she said.

Obama campaigned feverishly for the stimulus, pouring enormous amounts of political capital into its passage and touting it as a necessary step to head off economic catastrophe.

Some of the effects of the bill will be felt immediately, but many will be slow to kick in.

According to the Congressional Budget Office, for example, the stimulus would boost employment by between 800,000 and 2.3 million by the end of this year. By the end of 2010, the bill would create 3.6 million jobs, CBO estimated. See Capitol Report.

Details of the package

Tax cuts make up about one-third of the stimulus package. They include the $400 payroll-tax cut for workers, $100 less than Obama had proposed during his presidential campaign. Also included is relief from the alternative minimum tax for millions of middle-income taxpayers.

The bill spends $5.1 billion to allow businesses to more quickly deduct the cost of some investments from taxable income.

It also spends $6.6 billion on a tax-credit for first-time homebuyers.

Spending by the government makes up the rest of the stimulus bill. Read the bill.

Lawmakers agreed to spend $30 billion to modernize the electric grid, spur advanced battery manufacturing and fund energy efficiency projects. There is $29 billion included for road and bridge infrastructure construction and $19 billion for hospitals and doctors who computerize their medical records.

Obama made his latest appeal for passage of the measure on Friday, speaking before a business group at the White House. But he also cautioned that the bill is part of a multi-pronged strategy to revive the economy.

"This work will not be easy," Obama said. "Our recovery will likely be measured in years, not months. And all of us -- government, business, labor, and citizens -- will have responsibilities to meet."

Obama said his administration will also work to revitalize the housing market and the financial sector. Obama will announce a framework for his plan to help homeowners avoid foreclosure on Wednesday.

Passage of the legislation marked an important victory for Obama, who has been in office for less than a month.

But almost all congressional Republicans have panned the bill despite early attempts by Obama to bring them on board and begin his presidency with a show of bipartisanship.

"Democratic leaders barreled ahead with their trillion-dollar spending plan that everyone agrees won't work. The American people deserve better," Boehner said.

Meanwhile, U.S. stocks closed lower for the week, with financial shares pacing the declines, as investors retreated in the face of a long weekend and uncertainty over how much the government would help ailing banks. See Market Snapshot.