WASHINGTON — President Donald Trump issued the first veto of his presidency on Friday, overruling Congress to protect the emergency declaration he’d used to circumvent lawmakers to build his border wall.

Flanked by law enforcement officials as well as the parents of children killed by people in the country illegally, Trump maintained that he is not through fighting for his signature campaign promise, which stands largely unfulfilled 18 months before voters decide whether to grant him another term.

“Congress has the freedom to pass this resolution,” Trump said, “and I have the duty to veto it.”

A dozen defecting Republicans joined Senate Democrats in approving the joint resolution on Thursday, which capped a week of confrontation with the White House as both parties in Congress strained to exert their power in new ways. It is unlikely that Congress will have the two-thirds majority required to override Trump’s veto, though House Democrats will try nonetheless.

Despite the sharp rebuke from Congress, Friday’s event had the victory lap feel of a bill-signing ceremony. Trump was surrounded in the Oval Office by supporters who offered profuse thanks and frequent applause. After many had spoken, Trump dramatically signed his veto message and then held the document up for the cameras to capture.

He then distributed pens as mementos of the occasion.

Trump wants to use the emergency order to divert billions of federal dollars earmarked for defense spending toward the southern border wall. It still faces several legal challenges from Democratic state attorneys general and environmental groups who argue the emergency declaration was unconstitutional.

READ MORE: 3 legal arguments that could challenge Trump’s national emergency

Those cases could block Trump from diverting extra money to barrier construction for months or longer. American Civil Liberties Union, which filed one of the cases, said the veto is meaningless, like the declaration in the first place.

“Congress has rejected the president’s declaration, and now the courts will be the ultimate arbiter of its legality. We look forward to seeing him in court and to the shellacking that he will receive at the hands of an independent judiciary,” said Executive Director Anthony Romero.

House Speaker Nancy Pelosi called Trump’s veto a “lawless power grab,” and railed that, even after both chambers tried to stop him, Trump “has chosen to continue to defy the Constitution, the Congress and the will of the American people.”

Trump, however, insisted the situation on the southern border is “a tremendous national emergency,” adding, “our immigration system is stretched beyond the breaking point.”

Two years into the Trump era, a dozen Republicans, pushed along by Democrats, showed new willingness to take the political risk of defecting. The 12 GOP senators, including the party’s 2012 presidential nominee, Mitt Romney of Utah, joined the dissent over the emergency declaration order that would enable the president to seize for the wall billions of dollars Congress intended to be spent elsewhere.

“The Senate’s waking up a little bit to our responsibilities,” said Sen. Lamar Alexander, R-Tenn., who said the chamber had become “a little lazy” as an equal branch of government. “I think the value of these last few weeks is to remind the Senate of our constitutional place.”

Many lawmakers said the vote was not necessarily a rejection of the president or the wall, but protections against future presidents — namely a Democrat who might want to declare an emergency on climate change, gun control or any number of other issues.

Thursday’s vote was the first direct challenge to the 1976 National Emergencies Act, just as a Wednesday vote on Yemen was the first time Congress invoked the decades-old War Powers Act to try to rein in a president. That resolution seeking to end U.S. backing for the Saudi Arabian-led coalition fighting in Yemen was approved in the aftermath of the killing of journalist Jamal Khashoggi in the Saudi Consulate in Istanbul and is expected to be the subject of Trump’s second veto.

Despite the embarrassing defections, Trump’s grip on the party remains strong and the White House made it clear that Republicans resisting Trump could face political consequences. Ahead of the voting, Trump framed the issue as with-him-or-against-him on border security, a powerful argument with many.

But Friday, Trump said he had sympathy for Republicans who voted against him and emphasized that he never truly twisted the arms of lawmakers, because he knew there were not enough votes to override the veto.

“Look, they were doing what they have to do,” Trump said, insisting he “put no pressure” on lawmakers to vote against the resolution because he realized that the measure was likely to pass.

Still, a White House official said Trump won’t forget when senators who opposed him want him to attend fundraisers or provide other help. The official was not authorized to speak publicly on internal deliberations so spoke on condition of anonymity.

READ MORE: Trump says walls work. It’s much more complicated

Speaking in the Oval Office, Trump painted his usual portrait of a lawless and violent border. He cited “thousands and thousands” of gang arrests and claimed many of the asylum seekers released into the U.S. were “stone-cold killers,” ignoring data that shows immigrants are less likely to commit crime. He noted, correctly, a spike in the number of people coming to the border to claim asylum.

Trump initiated the showdown months ago when he all but dared Congress not to give him the $5.7 billion he was demanding to build the U.S.-Mexico wall, by threatening a federal government shutdown.

Congress declined and the result was the longest shutdown in U.S. history. Against the advice of GOP leaders, Trump invoked the national emergency declaration last month, allowing him to try to tap about $3.6 billion for the wall by shuffling money from military projects, and that drew outrage from many lawmakers. Trump had campaigned for president promising Mexico would pay for the wall.

AP writers Alan Fram, Lisa Mascaro, Catherine Lucey and Colleen Long contributed.