WASHINGTON — In a legal victory for President Trump, a federal appeals court panel on Wednesday ordered the dismissal of a lawsuit claiming that he had violated the Constitution by collecting profits from government guests at his hotel in the nation’s capital.

A three-judge panel of the United States Court of Appeals for the Fourth Circuit in Richmond, Va., found that the state of Maryland and the District of Columbia had no legal standing to sue Mr. Trump.

The judges roundly rejected the premise of the case, which claimed that the Trump International Hotel, blocks from the White House, is unfairly siphoning off business from hotels in which the local jurisdictions have a financial interest. The lawsuit, which alleges violations of the Constitution’s anti-corruption, or “emoluments,” clauses, was about to enter the evidence-gathering phase.

“The District and Maryland’s interest in enforcing the emoluments clauses is so attenuated and abstract that their prosecution of this case readily provokes the question of whether this action against the president is an appropriate use of the courts, which were created to resolve real cases and controversies,” the panel wrote in its decision.