A federal judge on Wednesday rejected President Trump’s latest effort to stop a lawsuit that alleges Trump is violating the Constitution by continuing to do business with foreign governments.

The ruling, from U.S. District Judge Peter J. Messitte in Greenbelt, Md., will allow the plaintiffs — the attorneys general of Maryland and the District of Columbia — to proceed with their case, which says Trump has violated little-used anti-corruption clauses in the Constitution known as emoluments clauses.

This ruling appeared to mark the first time a federal judge had interpreted those constitutional provisions and applied their restrictions to a sitting president.

If the ruling stands, it could bring unprecedented scrutiny to Trump’s businesses — which have sought to keep their transactions with foreign states private, even as their owner sits in the Oval Office.

Messitte’s 52-page opinion said that, in the modern context, the Constitution’s ban on emoluments could apply to Trump — and that it could cover any business transactions with foreign governments where Trump derived a “profit, gain or advantage.”

“This includes profits from private transactions, even those involving services given at fair market value,” Messitte wrote.

In the past year, the Trump Organization has held several large events paid for by foreign governments and reported about $150,000 in what it called “foreign profits” last year.

“In sum, Plaintiffs have plausibly alleged that the President has been receiving or is potentially able to receive ‘emoluments’ . . . in violation of the Constitution,” Messitte wrote.

Trump still owns his company, although he says he has stepped back from day-to-day control.

The Trump Organization and the Justice Department had urged Messitte to dismiss the case, arguing that the Founding Fathers had written this clause to stop officials from taking bribes — but not to stop them from doing business.

The company did not respond to requests for comment. The Justice Department released a short statement saying that it is reviewing the decision and that “we continue to maintain that this case should be dismissed.”

They could seek to appeal the ruling.

The plaintiffs now want to interview Trump Organization employees and search company records to determine which countries have spent money at Trump’s hotel in downtown Washington — and how much they spent. They may also seek to review Trump’s tax returns, which — unlike other recent presidents — he has not made public.

“We are one step closer to stopping President Trump from violating the Constitution’s original anti-corruption provisions,” said D.C. Attorney General Karl A. Racine (D), who brought this case along with Maryland Attorney General Brian E. Frosh (D).

Frosh said his staff was already preparing to seek financial documents related to the president’s D.C. hotel, which is located in a federally owned building, the Old Post Office. Before he became president, Trump won a federal contract to operate the hotel in the historic building.

Frosh suggested that, eventually, the added scrutiny could cause Trump to divest himself of the hotel.

“I think the decision bodes ill for his ownership of the Old Post Office hotel,” Frosh said.

The lawsuit, filed last year, is one of a spate of legal challenges that have sought to pry into Trump’s past business and legal dealings. Two other lawsuits — one filed by Democratic members of Congress, another by a D.C. wine bar that believes it lost business to Trump — have alleged that he is violating the emoluments clause.

Trump also has been sued for defamation by Stormy Daniels, an adult-film star who alleges she had an affair with Trump in 2006, and Summer Zervos, a former contestant on “The Apprentice.”

In addition, the New York attorney general has sued Trump and his oldest children, alleging that there was “persistently illegal conduct” at the Donald J. Trump Foundation, a charity they led. Separately, New York state’s tax-collecting authority is investigating that charity to determine whether criminal laws were broken, state officials have said.

This suit, filed by the attorneys general, cleared an initial hurdle in March. Back then, Messitte settled one legal question, ruling that the plaintiffs had legal standing to sue the president in the first place.

He also limited the scope of the case to Trump’s Washington hotel; previously, the plaintiffs had wanted to search for foreign-government spending at other Trump properties as well.

The plaintiffs were able to file in Maryland in part because of the economic disadvantage alleged to other hospitality businesses and their employees in the state.

The next unsettled question: What, exactly, is an emolument?

That remained unanswered for more than 200 years.

The Constitution bars federal officials from taking emoluments from any “King, Prince, or Foreign State.” The Founding Fathers’ intent had been to stop U.S. ambassadors overseas — emissaries from a new, poor, fragile country — from being bought off by jewels or payments from wealthy European states.

But the modern meaning of the clause had not been settled because most presidents — acting on the advice of their attorneys — had steered clear of business entanglements while in office.

Trump, on the other hand, has kept ownership of his business empire, including more than 10 hotels and golf clubs worldwide.

Some of his customers have been foreign governments. In particular, the Trump International Hotel on Pennsylvania Avenue in downtown Washington — just blocks from the White House — has rented out large ballrooms to the embassies of Kuwait and the Philippines and hosted leaders from Malaysia and Romania.

At the hearing in June, the plaintiffs had argued that when applied in a modern context, the Constitution’s ban on emoluments should cover transactions such as those.

They said emolument in this case should not mean just an outright gift but also any transaction that gave Trump “profit, gain or advantage.” That means it would apply to transactions in which a foreign government paid Trump’s company for a service or a hotel room.

To back up that argument, they cited 18th-century dictionaries showing that the term “emoluments” at the time the Constitution was written was defined more broadly than a simple gift or bribe.

But Justice Department lawyers, defending the president, said the proper definition was far more narrow.

They said the president is not breaking the law when foreign officials book rooms or hold events at his Washington hotel because they are paying for something and not giving Trump a gift.

If the plaintiffs are allowed to conduct “discovery” at Trump’s hotel — examining its books to identify its foreign customers — that could require the president to provide more detailed information about his personal finances.

Before Trump took office, his company said it would donate all “foreign profits” collected by the business to the federal Treasury. At the end of last year, the Trump Organization said it donated $151,470 in February. But it declined to explain the details behind that number — giving no information about which countries those profits came from or what the Trump Organization’s total revenue from foreign governments had been.