Both Mr. Trump and the company reimbursed Michael D. Cohen, the president’s former lawyer and fixer, for money that Mr. Cohen paid to buy the silence of Stormy Daniels, an adult film actress who said she had an affair with Mr. Trump. The president has denied the affair.

The federal prosecutors who charged Mr. Cohen said in a court filing in July that they had “effectively concluded” their investigation into possible crimes committed by the president’s company, the Trump Organization, or its executives. Neither the company nor any of its leaders were charged. However, the office of the Manhattan district attorney, Cyrus R. Vance Jr., is exploring whether the reimbursements violated any New York state laws.

The lawsuit filed on Thursday was the latest effort by the president and his legal team to stymie multiple attempts to obtain copies of his tax returns, which Mr. Trump said during the 2016 campaign that he would make public but has since refused to disclose.

Mr. Trump’s lawyers have sued to block attempts by congressional Democrats and New York lawmakers to gain access to his tax returns and financial records. They also challenged a California law requiring presidential primary candidates to release their tax returns, and a federal judge ruled in their favor on Thursday. But their arguments in those cases had been made on narrower grounds.

It is an open question whether sitting presidents are immune from prosecution while in office. The Constitution does not explicitly address the issue, and the Supreme Court has never answered the question.

Federal prosecutors are barred from charging a sitting president with a federal crime because the Justice Department — in memos written during the Nixon and Clinton administrations — has decided that presidents have temporary immunity while they are in office. The memos indicate that any wrongdoing should be addressed through impeachment, not the courts.

Those memos, however, do not bind the hands of state prosecutors.

“I think there is some force to the argument that states can’t be allowed to hobble presidents with local prosecutions, but there is certainly no authority for the claim that they cannot at least investigate while a president is in office,” said Frank O. Bowman III, a law professor at the University of Missouri and the author of “High Crimes and Misdemeanors: A History of Impeachment for the Age of Trump.”