The judge in former US President Donald Trump’s criminal trial has fined him $1,000 for contempt of court for the 10th time in connection with violating a court order, while warning him that any further violations could land him in prison.

Judge Juan Merchan said the nine $1,000 fines he has imposed so far did not appear to have deterred the tycoon from violating a gag order that prohibits him from making public comments about jurors, witnesses and the families of the judge and prosecutors if these statements are intended to influence the case.

Mercan said he was considering a prison sentence, “frankly a last resort” for a number of reasons, including the disruption of the trial, the political implications of jailing a leading presidential candidate before an election and the particular security challenges of jailing a former president.

But he said Trump’s “continued, willful” violations of the order amounted to a “direct attack on the rule of law.”

“I don’t want to impose a prison sentence and I’ve done everything I can to prevent it. But I will if I have to,” Mercan said from the stand in the absence of jurors.

New York law allows for fines of up to $1,000 or up to 30 days in jail for violating such a court-imposed order.

Merchan imposed a $1,000 fine today for an April 22 television interview in which the Republican former president said: “These jurors were picked too quickly — 95 percent Democratic. The district is almost all Democratic.”

Merchan last week fined Trump $9,000 for nine social media posts he found to be in violation of the order.

Merchan made the statement as Trump sat in the dock in a New York courtroom in the first criminal trial of a former US president.

Trump’s criminal hush-hush trial, now in its 12th day, has seen testimony from a top adviser and a former tabloid newspaper publisher about efforts during his first presidential bid to hush up stories of sexual misconduct.

New York prosecutors have accused Trump of falsifying business records to cover up a $130,000 payment to porn star Stormy Daniels, who he claims had sex with him in 2006. Trump has pleaded not guilty and denies ever having sex with Daniels.