In a stunning rebuke to Donald Trump, a dozen defecting Republicans joined Senate Democrats to block the national emergency that the US president declared so he could build his border wall with Mexico. The rejection capped a week of confrontation with the White House as both parties in Congress strained to exert their power in new ways. The 59-41 tally on Thursday, following the Senate's vote a day earlier to end US involvement in the war in Yemen, promised to force Mr Trump into the first vetoes of his presidency. He had warned against both actions. Moments after Thursday's vote, the president tweeted a single word of warning: "VETO!" Two years into the Trump era, a defecting dozen Republicans, pushed along by Democrats, showed a willingness to take that political risk. Twelve GOP senators, including the party's 2012 presidential nominee, Mitt Romney of Utah, joined the dissent over the emergency declaration order that would enable the president to seize for the wall billions of dollars Congress intended to use elsewhere. "The Senate's waking up a little bit to our responsibilities," said Republican Senator Lamar Alexander who said the chamber had become "a little lazy" as an equal branch of government. "I think the value of these last few weeks is to remind the Senate of our constitutional place." Many senators said the vote was not necessarily a rejection of the president or the wall, but protections against future presidents – namely a Democrat who might want to declare an emergency on climate change, gun control or any number of other issues. "This is constitutional question, it's a question about the balance of power that is core to our constitution," Mr Romney said. "This is not about the president. The president can certainly express his views as he has and individual senators can express theirs." Thursday's vote was the first direct challenge to the 1976 National Emergencies Act, just as Wednesday's on Yemen was the first time Congress invoked the decades-old War Powers Act to try to rein in a president. Seven Republicans joined Democrats in halting US backing for the Saudi Arabia-led coalition supporting the government in Yemen. Even though there ate not likely to be enough numbers to override a veto, the votes nevertheless sent a message from Capitol Hill. "Today's votes cap a week of something the American people haven't seen enough of in the last two years," said Senate minority leader Chuck Schumer, "both parties in the United States Congress standing up to Donald Trump." The result is a role-reversal for Republicans who have been reluctant to take on Mr Trump, bracing against his high-profile tweets and public reprimands. But now they are facing challenges from voters – some in states where senators face stiff elections next year – who are expecting more from Congress. Susan Collins, who is among those most vulnerable, said she was sure the president "will not be happy with my vote. But I'm a United States senator and I feel my job is to stand up for the Constitution, so let the chips fall where they may." Mr Trump's grip on the party, though, remains strong and the White House made it clear that Republicans resisting the president could face political consequences. Ahead of the voting, Mr Trump framed the issue as with-him-or-against-him on border security, a powerful argument with many. "A vote for today's resolution by Republican Senators is a vote for Nancy Pelosi, Crime, and the Open Border Democrats!" Trump tweeted. "Don't vote with Pelosi!" he said in another, referring to the speaker of the House. 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. "I don't think anybody's sending the president a message," said Jim Risch of Idaho, the GOP chairman of the Senate Foreign Relations Committee. He blamed the media for "reaching" to view every action "through the prism of the presidency, and that isn't necessarily the way it works here." Trump brought on the challenge months ago when he all but dared Congress not to give him the $5.7 billion he was demanding to build the U.S.-Mexico wall or risk a federal government shutdown. Congress declined and the result was the longest shutdown in U.S. history. Against the advice of GOP leaders, Trump invoked the national emergency declaration last month, allowing him to try to tap some $3.6 billion for the wall by shuffling money from military projects, and that drew outrage from many lawmakers. Trump had campaigned for president promising Mexico would pay for the wall. The Constitution gives Congress the power of the purse, and lawmakers seethed as they worried about losing money for military projects that had already been approved for bases at home and abroad. The Democratic-led House swiftly voted to terminate Trump's order. Senate Republicans spent weeks trying to avoid this outcome, up until the night before the vote, in a script that was familiar -- up until the gavel. The most promising was an effort from Sen. Mike Lee of Utah for legislation that would impose limits on future presidential actions. That would give senators some solace as they allowed Trump's order to stand. GOP senators huddled with Vice President Mike Pence and seemed optimistic the White House might support their plan. Then Trump called Lee in the middle of a private Republican lunch meeting and, in the time it took the senator to step out of the room to take the call, it was over. Trump was opposed. Lee and other senators were peeling off against the president. In a last-ditch effort the night before the vote, Lindsey Graham and other senators dashed to the White House to try once again for Trump's support to broker an alternative plan. Trump was frustrated by their arrival. They mostly failed. Trump did tweet ahead of the vote that he would be willing to consider legislation to adjust the 1976 law at some later time. That was enough of a signal for GOP Sen. Thom Tillis, who faces a potentially tough re-election in North Carolina, to flip his vote, according to a person unauthorized to discuss the private thinking and granted anonymity. Tillis had been one of the first senators to say he would oppose the declaration, writing in a Washington Post opinion column last month that there'd be "no intellectual honesty" in backing Trump after his repeated objections about executive overreach by President Barack Obama. But on Thursday, he did. Trump's public support in that tweet also helped bring on board several other Republicans, including Ted Cruz and Ben Sasse, who had been part of the private huddles, the person said. For some, said Sen. John Thune, the GOP whip, "the emergency declaration was just a bridge too far." ___ Associated Press writers Mary Clare Jalonick, Jill Colvin, Padmananda Rama and Andrew Taylor in Washington and Marc Levy in Harrisburg, Pennsylvania, contributed.