"This is what change looks like," Obama said a few moments later in televised remarks that stirred memories of his 2008 campaign promise of "change we can believe in."
Widely viewed as dead two months ago, the Senate-passed bill cleared the House on a 219-212 vote. Republicans were unanimous in opposition, joined by 34 dissident Democrats.
A second, smaller measure - making changes in the first - cleared the House shortly before midnight and was sent to the Senate, where Democratic leaders said they had the votes necessary to pass it quickly. The vote was 220-211.
Obama's young presidency received a badly needed boost as a deeply divided Congress passed legislation touching the lives of nearly every American. The battle for the future of the health insurance system - affecting one-sixth of the economy - galvanized Republicans and conservative activists looking ahead to November's midterm elections.
Far beyond the political ramifications - a concern the president repeatedly insisted he paid no mind - were the sweeping changes the bill held in store for Americans, insured or not, as well as the insurance industry and health care providers that face either smaller than anticipated payments from Medicare or higher taxes.
The nonpartisan Congressional Budget Office said the legislation awaiting the president's approval would extend coverage to 32 million Americans who lack it, ban insurers from denying coverage on the basis of pre-existing medical conditions and cut deficits by an estimated $138 billion over a decade. If realized, the expansion of coverage would include 95 percent of all eligible individuals under age 65.
For the first time, most Americans would be required to purchase insurance, and face penalties if they refused. Much of the money in the bill would be devoted to subsidies to help families at incomes of up to $88,000 a year pay their premiums.
The second measure, which House Democrats demanded before agreeing to approve the first, included enough money to close a gap in the Medicare prescription drug coverage over the next decade, starting with an election-season rebate of $250 later this year for seniors facing high costs.
Much of the cost would be covered by the pharmaceutical industry, which made a deal months ago with the White House in which it pledged to spend lavishly on television ads to help pass the bill.
It also included sweeping changes in the student loan program, an administration priority that has been stalled in the Senate for months. It would have the government originate all student loans, denying banks and other private lenders of a lucrative business they have long had. Much of the savings would go into increased Pell Grants for needy college students, but black and Hispanic colleges would also benefit.
For the president, the events capped an 18-day stretch in which he traveled to four states and lobbied more than 60 wavering lawmakers in person or by phone to secure passage of his signature domestic issue. According to some who met with him, he warned that the bill's demise could cripple his still-young presidency, and his aides hoped to use the victory on health care as a springboard to success on bills to tackle stubbornly high unemployment that threatens Democratic prospects in the fall.
Obama watched the vote in the White House's Roosevelt Room with Vice President Joe Biden and dozens of aides, exchanged high fives with Rahm Emanuel, his chief of staff, and then telephoned Speaker Nancy Pelosi with congratulations.
"We proved that we are still a people capable of doing big things," he said later in the White House East Room. "We proved that this government - a government of the people and by the people - still works for the people.
Crowds of protesters outside the Capitol shouted "just vote no" in a futile attempt to stop the inevitable taking place inside a House packed with lawmakers and ringed with spectators in the galleries above.
Across hours of debate, House Democrats predicted the larger of the two bills, costing $940 billion over a decade, would rank with other great social legislation of recent decades.
"We will be joining those who established Social Security, Medicare and now, tonight, health care for all Americans, said Pelosi, D-Calif., partner to Obama and Senate Majority Leader Harry Reid, D-Nev., in the grueling campaign to pass the legislation.
"This is the civil rights act of the 21st century," added Rep. Jim Clyburn of South Carolina, the top-ranking black member of the House.
Republicans readily agreed the bill would affect everyone in America, but warned repeatedly of the burden imposed by more than $900 billion in tax increases and Medicare cuts combined.
"We have failed to listen to America," said Rep. John Boehner of Ohio, leader of a party that has vowed to carry the fight into the fall's midterm elections for control of Congress.
The final obstacle to the bill's passage was cleared at mid-afternoon when Obama and Democratic leaders reached a compromise with anti-abortion lawmakers whose rebellion had left the outcome in doubt. The White House announced the president would issue an executive order pledging that no federal funds would be used for elective abortion, satisfying Rep. Bart Stupak of Michigan and a handful of like-minded lawmakers.
A spokesman for the U.S. Conference of Catholic Bishops expressed skepticism that the presidential order would satisfy the church's objections.
Republican abortion foes also said Obama's proposed order was insufficient, and when Stupak sought to counter them, a shout of "baby killer" could be heard coming from the Republican side of the chamber.
The measure would also usher in a significant expansion of Medicaid, the federal-state health care program for the poor. Coverage would be required for incomes up to 133 percent of the federal poverty level, $29,327 a year for a family of four. Childless adults would be covered for the first time, starting in 2014.
The insurance industry, which spent millions on advertising trying to block the bill, would come under new federal regulation. They would be forbidden from placing lifetime dollar limits on policies, from denying coverage to children because of pre-existing conditions and from canceling policies when a policyholder becomes ill.
Parents would be able to keep children up to age 26 on their family insurance plans, three years longer than is now the case.
A new high-risk pool would offer coverage to uninsured people with medical problems until 2014, when the coverage expansion would go into high gear.
Obama has said often that presidents of both parties have tried without success to achieve national health insurance, beginning with Theodore Roosevelt early in the 20th century.
The 44th president's quest to succeed where others have failed seemed at a dead end two months ago, when Republicans won a special election for a Massachusetts Senate seat, and with it, the votes to prevent a final vote.
But the White House, Pelosi and Reid soon came up with a rescue plan that required the House to approve the Senate-passed measure despite opposition to many of its provisions, then have both houses pass a fix-it measure incorporating numerous changes.
To pay for the changes, the legislation includes more than $400 billion in higher taxes over a decade, roughly half of it from a new Medicare payroll tax on individuals with incomes over $200,000 and couples over $250,000. A new excise tax on high-cost insurance policies was significantly scaled back in deference to complaints from organized labor.
In addition, the bills cut more than $500 billion from planned payments to hospitals, nursing homes, hospices and other providers that treat Medicare patients. An estimated $200 billion would reduce planned subsidies to insurance companies that offer a private alternative to traditional Medicare.
The insurance industry warned that seniors would face sharply higher premiums as a result, and the Congressional Budget Office said many would return to traditional Medicare as a result.
The subsidies are higher than those for seniors on traditional Medicare, a difference that critics complain is wasteful, but insurance industry officials argue goes into expanded benefits.