Rebel members of President Donald Trump's party have helped pass a vote to reject his declaration of an emergency on the US-Mexico border.
Twelve Republican senators broke party ranks to side with Democrats, approving a proposal to revoke the proclamation by 59-41.
The Democratic-controlled House of Representatives last month backed the measure.
Following Thursday's vote, Mr Trump tweeted: "VETO!"
Congress needs a two-thirds majority of both chambers to override a presidential veto, which is viewed as unlikely in this case.
Nevertheless, the vote will be seen as an embarrassing loss for the president on his signature domestic issue.
On Twitter, Mr Trump slammed the vote, calling it a "Democrat inspired Resolution which would OPEN BORDERS while increasing Crime, Drugs and Trafficking in our Country".
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!— Donald J. Trump (@realDonaldTrump) March 14, 2019
It comes just a day after the Senate rebuked him on foreign policy by approving a bill to end US support for the Saudi-led coalition in Yemen.
The Republican rebels on Thursday were Mitt Romney and Mike Lee of Utah, Marco Rubio of Florida, Roy Blunt of Missouri, Lamar Alexander of Tennessee, Pat Toomey of Pennsylvania, Rob Portman of Ohio, Jerry Moran of Kansas, Susan Collins of Maine, Lisa Murkowski of Alaska, Rand Paul of Kentucky, and Roger Wicker of Mississippi.
Thom Tillis of North Carolina changed his mind minutes before the vote and said he would oppose it.
The Republican president declared the emergency on 15 February after Congress refused funding for a wall on the US-Mexico border, a key campaign pledge.
He aims to circumvent Congress and build his long-promised barrier by raiding military budgets.
It could free up almost $8bn (£6bn) for the wall, which is still considerably short of the estimated $23bn cost of a barrier along almost 2,000 miles (3,200km) of border, but far more than the nearly $1.4bn begrudgingly allotted last month by Congress.
Where authority ends and overreach begins
Gary O'Donoghue, BBC News, Washington
By any standards this is a big rebellion by Republicans in the Senate and therefore a significant embarrassment for the president.
But what it's not, is a repudiation by them of his border wall policy which many of them support with varying degrees of enthusiasm.
Which begs the question: what were they bothered about?
In straightforward terms, the use of national emergency powers was seen as overreach by the president in two ways:
First, it is a pretty blatant attempt to bypass Congress's power of the purse - its constitutional right to raise and spend money.
The president had demanded billions for the wall, Congress hadn't agreed it; the government shutdown; and eventually the White House backed down. So going after the cash by this route was seen as not playing by the rules.
Second, Democrats and some Republicans regard this as a power grab that could set a dangerous precedent.
In the past, a constant refrain from Republicans was that former President Barack Obama regularly abused executive powers to do things he should have won congressional backing for.
And many of the current batch of Republican Senators will be in situ long after President Trump has departed. They might find it harder, if they'd backed the president now, to argue that a future Democratic president couldn't use emergency powers to, say, move on gun ownership or climate change.
So these rebellious Republicans get to have their cake and eat it. A marker has been laid down, but, with no chance of a veto override, the president still gets his way.
Or at least for the time being. Ultimately it will be the nine justices of the Supreme Court who will decide where legitimate authority ends and overreach begins.
Earlier on Thursday Mr Trump called Democrats "border deniers" and said any Republican opposing him would be casting "a vote for Nancy Pelosi".
The Democrats are “Border Deniers.” They refuse to see or acknowledge the Death, Crime, Drugs and Human Trafficking at our Southern Border!— Donald J. Trump (@realDonaldTrump) March 14, 2019
A vote for today’s resolution by Republican Senators is a vote for Nancy Pelosi, Crime, and the Open Border Democrats!— Donald J. Trump (@realDonaldTrump) March 14, 2019
He says the barrier is needed to combat illegal immigration on the southern border which he has described as a "crisis".
Democrats say the declaration is unconstitutional, Mr Trump has manufactured the border emergency and a wall would be a boondoggle.
The resolution to revoke the declaration passed the House by a margin of 245-182 in February. Thirteen Republicans sided with Democrats.
Lawmakers used a provision from the National Emergencies Act to overrule the president.
Most Republicans supported Mr Trump's decision and accused Democrats of ignoring an emergency at the border.
Senate Majority Leader Mitch McConnell says the declaration is "the predictable and understandable consequences of Democrats' decision to put partisan obstruction ahead of the national interest".
What did the rebel Republicans say?
The renegade conservatives largely condemned Mr Trump's declaration for setting up a dangerous presidential precedent while still agreeing with his border policies.
"This issue is not about strengthening our border security, a goal that I support and have voted to advance," Mrs Collins said ahead of the vote.
"It is a solemn occasion involving whether or not this body will stand up for its institutional prerogatives and will support the separation of powers enshrined in our constitution."
Mr Paul agreed Congress must fund border security, "but no president should go around Congress".
He added that if the declaration stands, it could allow a future "socialist-inclined president" to pass environmental or gun control legislation.
Mr Romney echoed a similar sentiment, calling the use of an emergency an "overreach" that "is an invitation to further expansion and abuse by future presidents".