The Republican-led Senate voted to nullify President Trump’s national emergency declaration to confront what he calls “a crisis” at the southern border — a stunning and rare rebuke for the commander-in-chief from the upper chamber.

A dozen defiant Republicans ignored pressure from Trump and joined all Democrats as the Senate voted 59-41 in favor of the resolution to block the president’s declaration.

Trump almost immediately renewed his vow to reverse the vote with a succinct tweet: “VETO!”

Later, he elaborated, repeating his usual talking points about the US-Mexico border.

“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!” he tweeted.

There appeared to be no chance that lawmakers could muster the two-thirds votes needed in both the House and Senate to override what would be Trump’s first presidential veto.

The veto would mean that barring successful court challenges by environmentalists, border landowners or others, the president will be able to shuffle billions in Defense

Department spending to begin construction of his long-promised border wall.

“I’ll do a veto. It’s not going to be overturned. It’s a border security vote,” Trump told reporters during an unrelated White House event.

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 US support for the ­Saudi-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.

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

“I’m sure he will not be happy with my vote,” said Sen. Susan Collins of Maine, a GOP defector who faces re-election next year.

“But I’m a United States senator and feel my job [is] to stand up for the Constitution. So let the chips fall where they may.”

GOP opposition grew as the Senate moved toward the showdown vote, with lawmakers warning that the president’s order was a usurpation of lawmakers’ power to control spending.

GOP Sens. Lamar Alexander of Tennessee and Mitt Romney of Utah became the sixth and seventh Republicans to say they’d vote for the resolution and others soon joined in.

“Never before has a president asked for funding, Congress has not provided it, and the president then has used the National Emergencies Act of 1976 to spend the money anyway,” Alexander said in a statement.

“The problem with this is that after a Revolutionary War against a king, our nation’s founders gave to Congress the power to approve all spending so that the president would not have too much power. This check on the executive is a crucial source of our freedom.”

Other Republican senators voting against Trump were Rand Paul of Kentucky, Mike Lee of Utah, Lisa Murkowski of Alaska, Jerry Moran of Kansas, Pat Toomey of Pennsylvania, Rob Portman of Ohio, Roger Wicker of Mississippi, Marco Rubio of Florida and Roy Blunt of Missouri.

“I share President Trump’s goal of securing our borders, but expanding the powers of the presidency beyond its constitutional limits is something I cannot support,” Moran wrote on Twitter.

Sen. Thom Tillis (R-NC) voted with Trump after previously saying he’d favor the resolution.

Trump wants to use his declaration to steer $3.6 billion more than Congress has approved for building ­border barriers.

He had earlier rejected a plan by Utah’s Lee that would have given GOP senators cover for opposing the resolution by passing a second rule that would let presidents only declare national emergencies for 30 days without congressional approval.

Democrats said there is no emergency at the border and that Trump’s declaration of “a crisis” was a political stunt.

They said Trump issued his order only because Congress agreed to provide less than $1.4 billion for barriers and he was desperate to fulfill his campaign promise to “Build the Wall.”

“Democrats and Republicans both know the sad truth: the president did not declare an emergency because there is one,” Senate Minority Leader Chuck Schumer (D-NY) said on the Senate floor.

“He declared an emergency because he lost in Congress and wants to get around it. 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.”

Schumer tweeted later that the two parties should work together more often to curb the president.

With AP