When Special Counsel Robert Mueller declined to recommend an indictment of President Trump earlier this year, an important factor was the long-standing view that presidents are immune from criminal prosecution while in office. So how come a federal judge in New York rejected the President’s efforts to block a criminal probe of his hush money payments to Stormy Daniels and Karen McDougal?

The Manhattan District Attorney’s office has been investigating whether the payments violated New York state law, and it therefore has subpoenaed records from the Trump Organization and other entities, including Trump’s accountants. According to the federal judge, Victor Marrero, there are several reasons why presidential immunity should not apply.

First, the President has claimed a very broad version of immunity—not simply preventing criminal charges against him, but also charges against others with whom he was associated. In addition, the President wants to stop not only indictments or prosecutions, but also investigations. Judge Marrero also was skeptical of the idea that Presidents need immunity from prosecution for all crimes. Finally, waiting to prosecute the President or his associates until he leaves office would prevent prosecutions for crimes whose statute of limitations has expired.

Judge Marrero’s decision won’t take effect immediately—the U.S. Court of Appeals for the Second Circuit imposed a stay pending a hearing and decision by its court. And it’s unlikely that the court of appeals will endorse his logic in full. Presidential immunity from prosecution is well-established even if not explicitly stated in the Constitution. And statutes of limitations can be extended. But Judge Marrero is on stronger ground when he criticizes the breadth of the President’s claim. Presidential immunity has an important place, but it shouldn’t be used to protect other persons.