WASHINGTON — President Donald Trump cannot be sued by local officials in Washington, DC, and Maryland for profiting from one of his hotels while he's in office, a federal appeals court ruled Wednesday.

The US Court of Appeals for the 4th Circuit handed Trump a significant win in the legal fight over whether he's been violating constitutional prohibitions against accepting things of value as an elected official, known as the emoluments clauses.

The three-judge panel found that DC and Maryland lacked standing to bring the case in the first place, and questioned whether the lawsuit was an "appropriate use of the courts."

"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 between the parties," Judge Paul Niemeyer wrote for the court.

The appeals court ordered the lawsuit dismissed. There is still a pending emoluments clause case against Trump in federal court in Washington filed by congressional Democrats. The district court judge in DC gave Democrats the green light to seek evidence from Trump, and Trump earlier this week petitioned the DC Circuit to delay that while he pursues an appeal.

Although Trump gave up day-to-day control of his business empire when he took office, he refused to divest his financial interests. The attorney general offices in DC and Maryland sued Trump in June 2017, arguing that when foreign, state, or local officials patronize Trump’s businesses, including the Trump International Hotel in downtown Washington, the president profits and receives a prohibited “emolument.”

There are two emoluments clauses in the US Constitution that are at issue in DC and Maryland's case — one that bars public officials from accepting such things of value from foreign governments, and one that applies to emoluments from federal, state, and local governments. The word “emolument” is generally defined as a financial benefit, but that definition has been one of the major issues in dispute in all of the cases against Trump.

The judge in Maryland, US District Judge Peter Messitte, agreed with DC and Maryland’s interpretation that the term covered a broad range of things of value, and rejected the Justice Department’s narrower position that it should cover only money that a public official received in exchange for official acts or an employer-employee arrangement.

The 4th Circuit didn't address the question of what an emolument is or whether the term would apply to profits Trump received from his businesses, however. The court ruled instead that Messitte had been wrong at an earlier stage of the case in finding that DC and Maryland had standing to file the lawsuit at all.

DC and Maryland's argument for standing had several parts. One was that they had "quasi-sovereign interests" in being treated fairly before the federal government. As long as Trump could profit from the hotel, they argued, that placed pressure on DC and Maryland to give his property favorable treatment in enforcing local business regulations, and to patronize the hotel if other state and local governments were doing business there.

DC and Maryland also argued that they had an interest in preserving a fair market for local businesses and properties that DC and Maryland themselves had a stake in, such as convention centers. Trump's ability to attract business from clients hoping to curry favor with him because of his position as president would give him an unlawful advantage, they claimed.

The 4th Circuit found DC and Maryland failed to show that Trump's profiting from his hotel had actually harmed their interests and that an injunction against the president would fix it. The attorneys general presented articles quoting foreign government officials saying they were staying at the hotel to please Trump, as well as examples of state officials patronizing the hotel while doing business with the administration, but Niemeyer wrote that it still required too much speculation to say that was why clients were choosing Trump's hotel over other local businesses.

And even if government officials were giving business to the hotel to gain favor with the president, the judge wrote, there was no reason to believe they'd stop if Trump could no longer profit from it.

Messitte had refused to give Trump permission to appeal his decisions — rulings denying early efforts at dismissal typically aren't appealable — so Trump petitioned the appeals court to step in, a request that Niemeyer noted was "an extraordinary one." However, he wrote, the lawsuit was "also an extraordinary one," highlighting the fact that it involved the president, that it was historically unprecedented, and that allowing the case to go further without resolving the legal issues in question could intrude on the affairs of a sitting president.

"Not only is this suit extraordinary, it also has national significance and is of special consequence," Niemeyer wrote.

DC Attorney General Karl Racine and Maryland Attorney General Brian Frosh released a joint statement saying the 4th Circuit "got it wrong" and that they would "continue to pursue our legal options to hold [Trump] accountable."

"Although the court described a litany of ways in which this case is unique, it failed to acknowledge the most extraordinary circumstance of all: President Trump is brazenly profiting from the Office of the President in ways that no other President in history ever imagined and that the founders expressly sought—in the Constitution to prohibit. We have not and will not abandon our efforts to hold President Trump accountable for violating the Nation’s original anti-corruption laws," Racine and Frosh said.

DC and Maryland could petition the full 4th Circuit to reconsider the case or ask the US Supreme Court to review it. The joint statement didn't specify what they planned to do next, and representatives of their offices did not immediately return requests for comment.

Justice Department spokesperson Kelly Laco said in a statement that they were pleased the court dismissed "this extraodinarily flawed case."

Trump was sued both in his official capacity as president and as an individual; his personal attorney in the case, William Consovoy, referred a request for comment to another Trump lawyer, Jay Sekulow. The 4th Circuit dismissed both sets of claims against Trump on the standing issue.

"Today's pair of decisions by the 4th Circuit Court of Appeals is a complete victory. The decision states that there was no legal standing to bring this lawsuit in the first place. This latest effort at Presidential harassment has been dismissed with prejudice," Sekulow said in a statement.