WASHINGTON -- Congress lopsidedly approved a border security compromise Thursday that would avert a second painful government shutdown, but a new confrontation was ignited - this time over President Donald Trump's plan to bypass lawmakers and declare a national emergency to siphon billions from other federal coffers for his wall on the Mexican boundary.Money in the bill for border barriers, about $1.4 billion, is far below the $5.7 billion Trump insisted he needed and would finance just a quarter of the 200-plus miles he wanted. The White House said he'd sign the legislation but act unilaterally to get more, prompting condemnations from Democrats and threats of lawsuits from states and others who might lose federal money or said Trump was abusing his authority.The uproar over Trump's next move cast an uncertain shadow over what had been a rare display of bipartisanship to address the grinding battle between the White House and lawmakers over border security.The Senate passed the legislation 83-16, with both parties solidly aboard. The House followed with a 300-128 tally, with Trump's signature planned Friday. Trump will speak Friday morning in the Rose Garden about border security, the White House said.House Democrats overwhelmingly backed the legislation, with only 19 - most of whom were Hispanic - opposed. Just over half of Republicans voted "no."Should Trump change his mind, both chambers' margins were above the two-thirds majorities needed to override presidential vetoes. Lawmakers, however, sometimes rally behind presidents of the same party in such battles.Lawmakers exuded relief that the agreement had averted a fresh closure of federal agencies just three weeks after a record-setting 35-day partial shutdown that drew an unambiguous thumbs-down from the public. But in announcing that Trump would sign the accord, White House Press Secretary Sarah Sanders also said he'd take "other executive action, including a national emergency,"In an unusual joint statement, House Speaker Nancy Pelosi, D-Calif., and Senate Minority Leader Chuck Schumer, D-N.Y., said such a declaration would be "a lawless act, a gross abuse of the power of the presidency and a desperate attempt to distract" from Trump's failure to force Mexico to pay for the wall, as he's promised for years."Congress will defend our constitutional authorities," they said. They declined to say whether that meant lawsuits or votes on resolutions to prevent Trump from unilaterally shifting money to wall-building, with aides saying they'd wait to see what he does.Democratic state attorneys general said they'd consider legal action to block Trump. Puerto Rico Gov. Ricardo Rossello told the president on Twitter "we'll see you in court" if he makes the declaration.Despite widespread opposition in Congress to proclaiming an emergency, including by some Republicans, Trump is under pressure to act unilaterally to soothe his conservative base and avoid looking like he's lost his wall battle.The abrupt announcement of Trump's plans came late in an afternoon of rumblings that the volatile president - who'd strongly hinted he'd sign the agreement but wasn't definitive - was shifting toward rejecting it. That would have infused fresh chaos into a fight both parties are desperate to leave behind, a thought that drove some lawmakers to ask heavenly help."Let's all pray that the president will have the wisdom to sign the bill so the government doesn't shut down," Sen. Charles Grassley, R-Iowa, said Thursday's Senate session opened.Moments before Sanders spoke at the White House, Senate Majority Leader Mitch McConnell, R-Ky., took to the Senate floor to announce Trump's decisions to sign the bill and declare an emergency.Sen. John Cornyn, R-Texas, told reporters there were two hours of phone calls between McConnell and the White House before there were assurances that Trump would sign.McConnell argued that the bill delivered victories for Trump over Pelosi. These included overcoming her pledge to not fund the wall at all and rejecting a Democratic proposal for numerical limits on detaining some immigrants, said a Republican speaking on condition of anonymity to describe private conversations.In a surprising development, McConnell said he would support Trump's emergency declaration, a turnabout for the Kentucky Republican, who like many lawmakers had opposed such action.Democrats say there is no border crisis and Trump would be using a declaration simply to sidestep Congress. Some Republicans warn that future Democratic presidents could use his precedent to force spending on their own priorities, like gun control. GOP critics included Maine Sen. Susan Collins, who said emergency declarations are for "major natural disasters or catastrophic events" and said its use would be of "dubious constitutionality."White House staff and congressional Republicans have said that besides an emergency, Trump might assert other authorities that could conceivably put him within reach of billions of dollars. The money could come from funds targeted for military construction, disaster relief and counterdrug efforts.Congressional aides say there is $21 billion for military construction that Trump could use if he declares a national emergency. By law, the money must be used to support U.S. armed forces, they say. The Defense Department declined to provide details on available money.With many of the Democrats' liberal base voters adamantly against Trump's aggressive attempts to curb immigration, four declared presidential hopefuls opposed the bill in the Senate: Cory Booker of New Jersey, New York's Kirsten Gillibrand, Elizabeth Warren of Massachusetts and Kamala Harris of California. Amy Klobuchar of Minnesota voted for it, as did Vermont independent Bernie Sanders, who is expected to join the field soon.Notably, the word "wall," the heart of many a chant at Trump campaign events and his rallies as president, is absent from the compromise's 1,768-page legislative and descriptive language. "Barriers" and "fencing" are the nouns of choice, a victory for Democrats eager to deny Trump even a rhetorical victory.The agreement, which took bargainers three weeks to strike, would also squeeze funding for Immigration and Customs Enforcement, or ICE, in an attempt to pressure the agency to detain fewer immigrants. To the dismay of Democrats, however, it would still leave an agency many of them consider abusive holding thousands more immigrants than last year.The measure contains money for improved surveillance equipment, more customs agents and humanitarian aid for detained immigrants. The overall bill also provides $330 billion to finance dozens of federal programs for the rest of the year, one-fourth of federal agency budgets.Trump sparked the last shutdown before Christmas after Democrats snubbed his $5.7 billion demand for the wall. The closure denied paychecks to 800,000 federal workers, hurt contractors and people reliant on government services and was loathed by the public.With polls showing the public blamed him and GOP lawmakers, Trump folded on Jan. 25 without getting any of the wall funds. His capitulation was a political fiasco for Republicans and handed Pelosi a victory less than a month after Democrats took over the House and confronted Trump with a formidable rival for power.Trump's descriptions of the wall have fluctuated, at times saying it would cover 1,000 miles of the 2,000-mile boundary. Previous administrations constructed over 650 miles of barriers.___Associated Press Congressional Correspondent Lisa Mascaro and reporters Padmananda Rama, Lolita Baldor and Matthew Daly contributed.