(Reuters) - Democratic lawmakers, states and others mulling legal challenges to President Donald Trump’s national emergency declaration to obtain funds to build a U.S.-Mexico border wall face an uphill and probably losing battle in a showdown likely to be decided by the conservative-majority Supreme Court, legal experts said.

After being rebuffed by the U.S. Congress in his request for $5.7 billion to help build the wall that was a signature 2016 campaign promise, Trump on Friday invoked emergency powers given to the president under a 1976 law. The move, according to the White House, enables Trump to bypass lawmakers and redirect money already appropriated by Congress for other purposes and use it for wall construction.

Peter Shane, a professor at Ohio State University’s Moritz College of Law, said challenges to the emergency declaration could end up as a replay of the legal battle against Trump’s travel ban targeting people from several Muslim-majority nations. The Supreme Court last year upheld the travel ban after lower courts had ruled against Trump, with the justices giving the president deference on immigration and national security issues.

Trump has painted illegal immigration and drug trafficking across the border as a national security threat.

“Courts are reluctant to second-guess the president on matters of national security,” Shane said.

Democrats, state attorneys general and at least one advocacy group have vowed to take the Republican president to court over the declaration.

“I’ll sign the final papers as soon as I get into the Oval Office and we’ll have a national emergency and then we’ll be sued,” Trump said at the White House.

The National Emergencies Act of 1976 has been invoked dozens of times by presidents without a single successful legal challenge. Congress never defined a national emergency in the law.

The legal experts said Trump’s declaration could be challenged on at least two fronts: that there is no genuine emergency and that Trump’s action overstepped his powers because under the U.S. Constitution Congress has authority over federal appropriations, not the president.

People gather to protest against U.S. President Donald Trump's declaration of a national emergency to build a border wall, at Trump International Hotel & Tower in Manhattan, New York, U.S. February 15, 2019. REUTERS/Andrew Kelly

Trump made the declaration after asking Congress to appropriate $5.7 billion for wall construction and lawmakers gave him none.

The Supreme Court has a 5-4 conservative majority that includes two justices appointed by Trump, Brett Kavanaugh and Neil Gorsuch. Chief Justice John Roberts has emerged as the court’s swing vote, and the decision on the legality of Trump’s action could come down to him.

“The handwriting is on the wall here,” said Steven Schwinn, a professor at the John Marshall Law School in Chicago. “The Supreme Court is almost certain to uphold President Trump’s emergency.”

Legal experts said the 1976 law gives presidents vast discretion. Trump plans to redirect $6.7 billion in federal funds to pay for a wall, money that would come from a U.S. treasury forfeiture fund, a defense counter-drug program and the military construction budget.

“The odds favor the president by a significant majority,” George Washington University Law School professor Jonathan Turley said. “He has the authority to make the declaration and he has the money.”

But the administration’s defense of Trump’s action may not be a smooth ride. Lawsuits could delay the use of funds the president is planning to tap, and legal experts said the bulk of funds may be tied up for years.

Trump is running for re-election next year and a loss would mean his presidency ends in January 2021. It is possible the legal fight over the emergency declaration might not be resolved by then.

“My guess is the money, the significant amount of money, won’t flow before the 2020 election,” Harvard Law School professor Mark Tushnet said.

Nancy Pelosi, the Democratic speaker of the House of Representatives, and Chuck Schumer, the Republican-led Senate’s top Democrat, said Trump actions “clearly violate the Congress’s exclusive power of the purse.”

Congress is unlikely to muster a veto-proof majority to vote down Trump’s emergency move. The Democratic-led House could try to sue, but courts generally do not allow Congress to litigate after lawmakers fail to legislate, the legal experts said.

States may lead the fight. California Governor Gavin Newsom and state Attorney General Xavier Becerra, both Democrats, said they anticipated they would sue, saying the state would be harmed because Trump’s action could drain money from its drug-fighting efforts, endangering its residents.

One possible advantage for California is that its case likely could at some point go to the San Francisco-based 9th U.S. Circuit Court of Appeals, which has dealt Trump setbacks on previous policies including the travel ban and potentially could impose or uphold an injunction against the emergency declaration.

Legal experts said landowners along the border could sue because they face the imminent threat of land seizure by the federal government to build the wall.

Opponents may have more traction arguing that the president is unlawfully trying to tap funds Congress appropriated for the Pentagon, the experts said. The Defense Department construction money that Trump wants has almost never been used for domestic construction. In addition, Congress required the money be spent supporting military operations, and opponents could argue the border wall fails to qualify.