This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

WASHINGTON (AP) — The Republican-run Senate rejected President Donald Trump’s declaration of a national emergency at the southwest border on Thursday, setting up a veto fight and dealing him a conspicuous rebuke as he tested how boldly he could ignore Congress in pursuit of his highest-profile goal.

The Senate voted 59-41 to cancel Trump’s February proclamation of a border emergency, which he invoked to spend $3.6 billion more for border barriers than Congress had approved. Twelve Republicans joined Democrats in defying Trump in a showdown many GOP senators had hoped to avoid because he commands die-hard loyalty from millions of conservative voters who could punish defecting lawmakers in next year’s elections.

With the Democratic-controlled House’s approval of the same resolution last month, Senate passage sends it to Trump. He has shown no reluctance to casting his first veto to advance his campaign exhortation to “Build the Wall,” and it seems certain Congress will lack the two-thirds majorities that would be needed to override him.

“I’ll do a veto. It’s not going to be overturned,” Trump told reporters in the Oval Office. “It’s a border security vote.”

Though Trump seems sure to prevail in a veto battle, it remains noteworthy that lawmakers of both parties resisted him in a fight directly tied to his cherished campaign theme of erecting a border wall. The roll call came just a day after the Senate took a step toward a veto fight with Trump on another issue, voting to end U.S. support for the Saudi Arabian-led coalition’s war in Yemen.

In a measure of how remarkable the confrontation was, Thursday was the first time Congress has voted to block a presidential emergency since the National Emergency Act became law in 1976.

Even before Thursday’s vote, there were warnings that GOP senators resisting Trump could face political consequences. A White House official said Trump won’t forget when senators who oppose him want him to attend fundraisers or provide other help. The official spoke on condition of anonymity because they were not authorized to speak publicly on internal deliberations.

At the White House, Trump did not answer when reporters asked if there would be consequences for Republicans who voted against him.

Underscoring the political pressures in play, Sen. Thom Tillis, R-N.C., who last month became one of the first Republicans to say he’d oppose Trump’s border emergency, said Thursday he’d vote to support it. Tillis, who faces a potentially difficult re-election race next year, cited talks with the White House that suggest Trump could be open to restricting presidential emergency powers in the future.

Still, the breadth of opposition among Republicans suggested how concern about his declaration had spread to all corners of the GOP. Republican senators voting for the resolution blocking Trump included Mitt Romney of Utah, the party’s 2012 presidential candidate; Mike Lee of Utah, a solid conservative; Maine moderate Susan Collins and Lamar Alexander of Tennessee, a respected centrist.

Republicans control the Senate 53-47. Democrats solidly opposed Trump’s declaration.

Presidents have declared 58 national emergencies since the 1976 law, but this was the first aimed at accessing money that Congress had explicitly denied, according to Elizabeth Goitein, co-director for national security at New York University Law School’s Brennan Center for Justice.

Trump and Republicans backing him said there is a legitimate security and humanitarian crisis at the border with Mexico. They also said Trump was merely exercising his powers under the law, which largely leaves it to presidents to decide what a national emergency is.

“The president is operating within existing law, and the crisis on our border is all too real,” said Senate Majority Leader Mitch McConnell, R-Ky.

Opponents said Trump’s assertion of an emergency was overblown. They said he issued his declaration only because Congress agreed to provide less than $1.4 billion for barriers and he was desperate to fulfill his campaign promise on the wall. They said the Constitution gives Congress, not presidents, control over spending and said Trump’s stretching of emergency powers would invite future presidents to do the same for their own concerns.

“He’s obsessed with showing strength, and he couldn’t just abandon his pursuit of the border wall, so he had to trample on the Constitution to continue his fight,” said Senate Minority Leader Chuck Schumer, D-N.Y.

Republicans had hoped that Trump would endorse a separate bill by Utah’s Sen. Lee constraining emergency declarations in the future and that would win over enough GOP senators to reject Thursday’s resolution.

But Trump told Lee on Wednesday that he opposed Lee’s legislation, prompting Lee himself to say he would back the resolution.

The strongest chance of blocking Trump remains several lawsuits filed by Democratic state attorneys general, environmental groups and others.

On Twitter, Trump called on Republicans to oppose the resolution, which House Speaker Nancy Pelosi, D-Calif., helped drive through the House last month.

“Today’s issue is BORDER SECURITY and Crime!!! Don’t vote with Pelosi!” he tweeted, invoking the name of a Democrat who boatloads of GOP ads have villainized in recent campaign cycles.

Sen. Lindsey Graham, R-S.C., who is backing Trump, went to the White House late Wednesday with other senators to see if some compromise could be reached that would help reduce the number of GOP senators opposing Trump, according to a person familiar with the visit who described it on condition of anonymity. The effort fell short.

The National Emergency Act gives presidents wide leeway in declaring an emergency. Congress can vote to block a declaration, but the two-thirds majorities required to overcome presidential vetoes make it hard for lawmakers to prevail.

Lee had proposed letting a presidential emergency declaration last 30 days unless Congress voted to extend it. That would have applied to future emergencies but not Trump’s current order unless he sought to renew it next year.