WASHINGTON — Marking a victory that appeared beyond reach two months ago, President Barack Obama on Tuesday signed into law a sweeping rewrite of health-care policy that will touch every American and affect one-sixth of the economy.

“Today, after almost a century of trying, today after over a year of debate, today after all the votes have been tallied, health insurance reform becomes law in the United States of America,” Obama said before putting his signature on the measure.

The East Room, the largest in the White House, was packed for the ceremony with Democratic lawmakers who supported the bill and advocates for the cause of revamping the health-care system. They included Victoria Kennedy, the widow of Sen. Edward Kennedy, who made enacting the legislation one of his central goals.

Obama spent a year and much of his political capital pushing the legislation through Congress. That struggle, which some Democrats have compared to the fight for civil rights legislation in the 1960s, is likely to shape Obama’s presidency as well as the makeup of Congress next year. The law passed Congress without getting a single Republican vote, a partisan divide promises to make health care the defining issue in November’s elections.

The coming fight “will make last August look like a love fest,” said Sen. Judd Gregg, R-N.H., said Monday, referring to town hall meetings that drew protests over Obama’s health-care package, the largest revamp in 45 years.

House Republican leader John Boehner of Ohio said in a statement that by signing the bill Obama “is abandoning our founding principle that government governs best when it governs closest to the people.” The law will have “devastating consequences,” he said.

The new law, phased in over several years, extends coverage to tens of millions uninsured Americans, imposes new taxes on the highest wages earners, calls for fees on health-care companies, provides hundreds of billions in Medicare savings and would cost almost $1 trillion.

As part of the bargain for passage in the House, the law must be accompanied by a series of legislative repairs now pending in the Senate, where Republicans vow to offer dozens of amendments to force changes and reduce its costs.

As a measure of the historic nature of the event, some lawmakers and guests posed for pictures at the front of the room before Obama entered. The crowd stood and applauded upon the arrival of Rep. John Dingell, D-Mich., who has been advocating for universal health-care coverage since coming to Congress in 1955.

Rep. Patrick Kennedy, D-R.I., the son of Edward Kennedy, showed attendees a copy of his father’s original bill calling for national health insurance in 1970.

“My dad’s first national health insurance bill,” he said to reporters.

When the president and Vice President Joe Biden came into the East Room, the crowd broke into applause and began chanting an Obama campaign slogan, “Fired up, ready to go.”

“To state the obvious, this is a historic day,” Biden said. He credited Obama’s “fierce advocacy” on behalf of his health-care proposal for delivering on a campaign promise.

“You’re the guy that made it happen,” Biden said to Obama. “You’ve done what generations, not just ordinary but great men and women have attempted to do.”

In his remarks, Obama cited the line of presidents and lawmakers who have championed expanded health care coverage for Americans from Teddy Roosevelt to Kennedy.

He also said he recognized that many Democratic members of Congress “took their lumps” during the debate. That prompted one lawmaker to shout from the audience “Yes, we did,” provoking laughter.

The president is following up the signing ceremony by giving an address at the Interior Department to about 600 lawmakers, cabinet members and people in the health-care industry, including doctors, nurses, advocates and consumers who face rising premiums or insurance-coverage problems.