Sixteen states on Monday filed a federal lawsuit challenging President Trump’s national-emergency declaration to pay for a wall along the U.S.-Mexico border, setting up a showdown with the administration that could go to the Supreme Court and last through the 2020 election.

The complaint, filed in California’s Northern District, seeks judicial intervention to stop the order and accuses Mr. Trump of “flagrant disregard for the separation of powers.” The suit claims that the president’s move undermined Congress by redirecting...