U.S. House Speaker Paul Ryan (R-Wis.) signs a bill repealing Obamacare at the U.S. Capitol in Washington on Thursday, Jan. 7, 2016. President Obama on Friday vetoed the legislation. (REUTERS/Jonathan Ernst)

President Obama vetoed the Republican-backed repeal of his signature health-care reform Friday, following through on a pledge to beat back any threat to the centerpiece of his domestic legacy.

“Rather than refighting old political battles by once again voting to repeal basic protections that provide security for the middle class, Members of Congress should be working together to grow the economy, strengthen middle-class families, and create new jobs,” Obama said in a message to Congress. “Because of the harm this bill would cause to the health and financial security of millions of Americans, it has earned my veto.”

The bill, which also blocks federal funding for Planned Parenthood, passed the House on Wednesday 240 to 181, with only four members crossing party lines. The Senate passed the bill 52 to 47 last month.

[Congress sends health-care repeal to Obama, setting up certain veto]

Neither margin is large enough to override Obama’s veto, but Republicans say the fact that they were able to find a path around a Democratic filibuster in the Senate and pass the repeal bill gives them momentum going into the 2016 presidential race.

House Speaker Paul D. Ryan (R-Wis.) said Friday that it was “no surprise that someone named Obama vetoed a bill repealing Obamacare.” But he said the House will hold a vote to override the veto regardless, “taking this process all the way to the end under the Constitution.”

Ryan signed the bill in a Capitol ceremony Thursday, surrounded by dozens of fellow GOP lawmakers. “If there is one story that is being told here today, it is this: the idea that Obamacare is the law of the land for a long time is a myth,” he said. “We will see this law either collapse under its own weight, or we will see this law, in the next session of Congress as we’re proving here today, be repealed and signed and replaced by a Republican president.”

The veto is the sixth Obama has delivered since Republicans took control of the Senate last January. Previous measures that have garnered Obama vetoes include bills to approve the construction of the Keystone XL pipeline, to override regulations governing union elections and to regulate carbon emissions from coal-fired power plants.

Numerous other GOP-backed bills have failed in the Senate, where Democrats hold enough votes to filibuster any bill they are unified in opposing. To pass the Obamacare repeal bill, Republican lawmakers used the complex budget procedure known as reconciliation to avoid a filibuster in this case — the same procedure Democrats used to pass the bill in 2009 when they held both the House and the Senate.