The Senate passed a resolution Thursday to overturn President Trump’s declaration of a national emergency at the U.S.-Mexico border, with 12 Republicans joining all the Democrats to deliver a rare bipartisan rebuke of the president.

The disapproval resolution passed the House last month, so the 59-to-41 Senate vote will send the measure to the president’s desk. Trump intends to use the first veto of his presidency to strike it down, and Congress does not have the votes to override the veto.

“VETO!” Trump tweeted moments after the vote.

A short while later he added, “I look forward to VETOING the just passed Democrat inspired Resolution which would OPEN BORDERS while increasing Crime, Drugs, and Trafficking in our Country. I thank all of the Strong Republicans who voted to support Border Security and our desperately needed WALL!”

The Senate vote stood as a rare instance of Republicans breaking with Trump in significant numbers on an issue central to his presidency — the construction of a wall along the southern border.

For weeks, Trump had sought to frame the debate in terms of immigration, arguing that Republican senators who supported border security should back him on the emergency declaration, which would allow him to redirect military construction funds to the wall in the absence of an appropriation from Congress.

But for many GOP lawmakers, it was about what they saw as a bigger issue: the Constitution itself, which grants Congress — not the president — control over government spending. By declaring a national emergency to bypass Congress, Trump was violating the separation of powers and setting a dangerous precedent, these senators argued.

“It’s imperative for the president to honor Congress’s constitutional role to make policy and appropriate money,” Sen. Rob Portman (R-Ohio) said Thursday on the Senate floor as he announced his vote in favor of the disapproval resolution. “A national emergency declaration is a tool to be used cautiously and sparingly.”

Because Trump’s veto is unlikely to be overturned, Thursday’s outcome was more a political setback than a substantive one. The national emergency declaration will remain in effect, although it faces numerous court challenges that could delay aspects of its implementation for months or even years. Republicans who voted with Trump and against the disapproval resolution said the president was acting within his authority under the National Emergencies Act and taking necessary steps to address a humanitarian and drug crisis at the border that Democrats had ignored.

“There is a crisis at the border, and Nancy Pelosi and Chuck Schumer have prevented a solution,” said Sen. Cory Gardner (R-Colo.), naming the House speaker and Senate minority leader. “It should never have come to this, but in the absence of congressional action, the president did what Nancy Pelosi and Chuck Schumer refused to do.”

Many GOP senators agonized at length before deciding how to vote, with significant numbers of them — including Portman and Gardner, who is up for reelection next year — waiting until Thursday to announce their positions.

In the end, only one Republican who is up for reelection next year — Susan Collins of Maine — voted for the disapproval resolution.

In addition to Collins and Portman, the other GOP senators voting for the resolution were Lamar Alexander (Tenn.), Roy Blunt (Mo.), Mike Lee (Utah), Jerry Moran (Kan.), Lisa Murkowski (Alaska), Rand Paul (Ky.), Mitt Romney (Utah), Marco Rubio (Fla.), Patrick J. Toomey (Pa.) and Roger Wicker (Miss.).

Sen. Thom Tillis (R-N.C.), another senator up for reelection in a politically divided state, had announced last month that he would vote for the disapproval resolution. He wrote an opinion piece in The Washington Post at the time arguing there would be “no intellectual honesty” in supporting executive overreach by Trump that he had opposed under President Barack Obama.

But on Thursday, Tillis cast his vote with the president, saying he was reassured by indications that Trump would support changes to the National Emergencies Act itself to rein in presidential powers going forward, and that his GOP colleagues also backed such legislation.

Tillis’s flip-flop highlighted the political pressure Republicans were under as they contemplated crossing the president on an issue at the forefront of his agenda.

“I have received a lot of feedback over the past few weeks,” Tillis acknowledged on the Senate floor as he explained his change of heart. “But what it allowed me to do is engage in a discussion with some of my colleagues here, and with the White House, over the past couple of weeks that has been very, very productive.”

Thursday’s vote followed numerous failed efforts at compromise by vacillating GOP senators, including one Wednesday evening in which a trio of Republican senators — Lindsey O. Graham of South Carolina, Ted Cruz of Texas and Ben Sasse of Nebraska — showed up nearly unannounced at the White House, interrupting Trump at dinner in a last-ditch effort to craft a compromise.

Their efforts failed, and Graham, Cruz and Sasse all ended up voting against the disapproval resolution.

“I said, ‘Thank you for meeting with us. Sorry we ruined your dinner.’ And again, if it’d been me, I would have kicked us out after about five minutes,” Graham said later.

Ahead of the vote, Trump took to Twitter to goad his critics and insist that defectors would be siding with Pelosi (D-Calif.).

“A vote for today’s resolution by Republican Senators is a vote for Nancy Pelosi, Crime, and the Open Border Democrats!” Trump wrote.

The president said he would support GOP efforts to update the National Emergencies Act at a later date, “but today’s issue is BORDER SECURITY and Crime!!! Don’t vote with Pelosi!”

Pelosi said after the vote: “This is not an emergency, and the Congress has declared in a strong bipartisan voice that the president’s fearmongering doesn’t make it one.”

The House is likely to hold a vote on an effort to override Trump’s veto on March 26, according to a Democratic leadership aide who spoke on the condition of anonymity ahead of a public announcement. Although it’s expected to fall short of the necessary two-thirds majority, House Democrats view it as an important opportunity to underscore their stance and get Republicans on the record again.

“I think we should vote on this. This is the most consequential constitutional vote that we have taken in a generation about the balance of powers,” said Rep. Joaquin Castro (D-Tex.), who sponsored the disapproval resolution when it passed the House. At that time, 13 House Republicans joined Democrats in supporting it.

Concern among GOP senators has focused on Trump’s use of the National Emergencies Act to grab $3.6 billion appropriated by Congress for military construction projects nationwide and use it to build barriers along the border instead.

Lawmakers of both parties were frustrated that they never got details from the Pentagon about what projects would be canceled or delayed to pay for Trump’s wall.

Several lawmakers had sought to convince Trump to withdraw the national emergency declaration. They argued that he could get plenty of money for border barriers by drawing on the $1.375 billion appropriated by Congress, plus an additional $3.1 billion — or more than that, if needed — from Pentagon and Treasury Department accounts that can be tapped without use of an emergency declaration.

But Trump showed little interest in this approach. When he declared the national emergency on Feb. 15, it followed weeks of negotiations with Congress that yielded a fraction of the money he had sought for his wall.

Although Senate Majority Leader Mitch McConnell (R-Ky.) had warned publicly against the tactic, McConnell went along with Trump’s emergency declaration as the price for avoiding another government shutdown after a record-long 35-day funding lapse that consumed Christmas and much of January.

The emergency declaration underscored Trump’s determination to build many more miles of border barriers than Congress had agreed to. Trump had promised that Mexico would pay for the wall.

Graham declined to specify what exactly was discussed when he and the other senators interrupted the president’s dinner Wednesday night, but said it focused on satisfying senators’ concerns about dipping into the military construction budget.

The last-minute intervention was a final attempt by Republicans to find some kind of compromise, as they chose between siding with Trump or crossing him on Thursday’s vote. But Trump repeatedly shot down the GOP’s attempts at dealmaking, calling Lee during a private Republican lunch Wednesday to reject a proposal to amend the National Emergencies Act. Shortly after that, Lee announced he would be voting for the disapproval resolution.

The vote came a day after the Senate called for an end to U.S. military support for the Saudi-led war in Yemen, marking the second instance in two days that a Senate that has been mostly deferential to Trump took a position against him.