Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — The Senate voted 59-41 on Thursday to cancel President Donald Trump's national security declaration to fund a wall on the border, as 12 Republicans joined Democrats in an unusual rebuke of the president.

Trump has vowed to veto the measure, which would block him from making an end run around Congress to obtain billions of federal dollars that have been set aside for other purposes to build the wall he has promised along the border with Mexico.

The vote could play a role in coming lawsuits challenging the emergency declaration. Before the vote, nine Republican senators said they would support the measure: Jerry Moran of Kansas, Rand Paul of Kentucky, Pat Toomey of Pennsylvania, Rob Portman of Ohio, Mike Lee of Utah, Mitt Romney of Utah, Lamar Alexander of Tennessee, Lisa Murkowski of Alaska, and Susan Collins of Maine.

The number of GOP defections grew when the final votes were tallied to include Marco Rubio of Florida, Roy Blunt of Missouri and Roger Wicker of Mississippi. Moran and Alexander have announced that they don't plan to seek re-election next year, while Collins is up for re-election in 2020.

Senate Leader Mitch McConnell, R-Ky., conceded last week that the resolution would clear the 51-vote threshold needed to pass.

After the measure passed, Trump tweeted simply:

VETO! — Donald J. Trump (@realDonaldTrump) March 14, 2019

The measure, passed by the House of Representatives in February, now heads to Trump's desk. It would be the first veto of his presidency.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Earlier at the White House, the president told reporters that the result of the vote didn't matter.

"I’ll probably have to veto and it’s not going to be overturned, and we’re going to have our whole thing," he said.

He added, "The legal scholars all say it’s totally constitutional. It’s very important, it’s really a border security vote. It’s pure and simple — it’s a vote for border security, it’s a vote for no crime."

House Speaker Nancy Pelosi, D-Calif., said in a statement after the measure passed that Trump's declaration "is an unlawful power grab that does violence to the Constitution and fundamentally alters the separation of powers."

"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," Pelosi said.

In a tweet Thursday morning seemingly aimed at swaying lawmakers on the fence, Trump said that if Congress wanted to "update the law" that grants the president power to declare a national emergency, "I will support those efforts, but today’s issue is BORDER SECURITY and Crime!!! Don't vote with Pelosi!"

Romney, a frequent Trump critic, said that he would vote in favor of the resolution because of the broader implication of Trump's declaration, which the president wants to use to pay for a border wall Congress has refused to fund.

"I will vote today for the resolution of disapproval," Romney said. "This is a vote for the constitution and for the balance of powers that is at its core. For the executive branch to override a law passed by Congress would make it the ultimate power rather than a balancing power."

He added, "This is not a vote against border security. In fact, I agree that a physical barrier is urgently needed to help ease the humanitarian crisis at the southern border, and the administration already has $4.5 billion available within existing authority to fund a barrier — even without an emergency declaration."

Alexander, in announcing on the Senate floor that he would support the measure, called the declaration a "dangerous precedent."

Senate Minority Leader Chuck Schumer, D-N.Y., slammed Trump for declaring an emergency "because he lost with Congress."

"He had to trample on the Constitution to continue his fight," Schumer said.

Should Trump follow through on his veto threat, it is unlikely that Congress would be able to overturn it.

Trump declared the national emergency weeks after the longest government shutdown in U.S. history, lasting more than a month, which followed Congress' refusal to acquiesce to his demand for more than $5 billion in funding to build a massive wall along the southern border with Mexico. Trump used the emergency declaration in hopes of redirecting billions of federal dollars to build the wall without congressional approval.

Trump on Thursday labeled the Democratic lawmakers opposed to his emergency declaration "'Border Deniers.'"

"They refuse to see or acknowledge the Death, Crime, Drugs and Human Trafficking at our Southern Border!" he tweeted.