A New York judge ruled Monday against a bid by US President-elect Donald Trump to have his conviction for covering up hush money payments to a porn star thrown out on immunity grounds.

Judge Juan Merchan said in the ruling that a Supreme Court decision granting presidents sweeping immunity for official acts did not apply as testimony at the trial related “entirely to unofficial conduct entitled to no immunity protections.”

“Defendant’s motion to dismiss the indictment and vacate the jury verdict… is denied.”

Monday’s ruling raises the prospect that Trump could become the first president to enter the White House with a felony conviction, pending his appeal against the jury’s verdict.

Trump has sought to have the case moved to federal court, which would give him the power to end the case himself as soon as he retook the presidency.

He has also challenged the conviction on a number of technical grounds, including alleging juror misconduct.

Trump has long opposed the criminal process brought against him after he paid a porn star for her silence over an alleged sexual encounter, and then covered up the payments in an effort to boost his chances in 2016’s election.

The judge in the only criminal case against Trump that has gone to trial had indefinitely postponed Trump’s sentencing at a hearing on November 22, given his win in the November 5 presidential election.

Trump’s legal team had cited a landmark July ruling from the Supreme Court that gives US presidents sweeping immunity for official acts committed while in office as justification for their request to throw out this conviction.

‘A stay of proceedings?’

Prosecutors argued that Trump’s bid to have the case thrown out was “well beyond” what was needed to protect the presidency.

But prosecutors accepted Trump should receive special treatment to prevent the case interfering with his second White House stint.

“Multiple accommodations well short of dismissal… would satisfy that objective, including a stay of proceedings during his term in office,” the prosecutor’s office said ahead of Merchan’s ruling.

Prosecutors convinced a jury during the hush money trial that Trump’s payments were made to cover up a scandal that would have hurt his 2016 campaign against Democrat Hillary Clinton, whom he ultimately beat.

Last month, Trump’s lawyers separately asked New York Attorney General Letitia James to quash a civil judgment against him for fraud and a $464 million penalty “for the greater good of the country” as he prepares to return to power.

In a letter to Trump’s lawyer John Sauer published on social media, New York Deputy Solicitor General Judith Vale denied the request.