A Manhattan judge briefly ordered Donald J. Trump to the witness stand on Wednesday after accusing him of breaking a gag order with critical comments that seemed aimed at a law clerk, and then fined him $10,000.
The judge, Arthur F. Engoron, who is presiding over Mr. Trump’s civil fraud trial, issued the punishment after finding that Mr. Trump earlier in the day had violated an order that prevents him from discussing court staff. Mr. Trump said that his comments had referred not to the clerk, whom he had previously attacked, but to his former lawyer, Michael D. Cohen, a witness.
From the stand, Mr. Trump, wearing a navy suit and curtailing his usual monologue, said that while he had not been speaking about the clerk, Allison Greenfield, he thought she was “maybe unfair, and I think she’s very biased against me.”
Mr. Trump left the stand after about three minutes. Justice Engoron said that he had not found the former president credible and levied the fine.
The episode was remarkable and wholly unexpected: While Mr. Trump has been voluble in his own defense outside the courtroom, he had not testified in open court in a decade, and as soon as he did, the judge found against him. For the former president, who is expected to testify later in the civil fraud trial and has been criminally indicted four times, it was a discomfiting preview of what may await.
The incident that put Mr. Trump on the stand began during a break in the proceedings on Wednesday when he expressed a criticism that is allowed under the order, calling Justice Engoron partisan. But Mr. Trump added: “with a person who’s very partisan sitting alongside him. Perhaps even much more partisan than he is.”
After the break, the judge said he was concerned that the overheated environment could result in real danger.
“I am very protective of my staff,” Justice Engoron said, adding, “I don’t want anyone to get killed.”
A lawyer for Mr. Trump, Christopher M. Kise, protested that the former president had been referring to Mr. Cohen, his former fixer, who was testifying for a second day. Mr. Trump did clearly refer to Mr. Cohen immediately after the initial comment, calling him a “discredited witness.”
The judge responded that the target of the comments had seemed clear to him and called the hearing.
Mr. Trump trotted to the witness stand and faced the courtroom for his brief questioning by the judge. Justice Engoron asked whether he had in the past referred to Ms. Greenfield as “partisan” and whether he always refers to Mr. Cohen as “Michael Cohen.” His lawyers, from the defense table, assured the judge that Mr. Trump has far more derogatory ways of referring to Mr. Cohen.
Justice Engoron had already fined Mr. Trump $5,000 last week for comments he made about Ms. Greenfield, whom the former president was barred from discussing after he attacked her on social media in the trial’s opening days.
That first violation was something of a technicality: Though the comments about Ms. Greenfield were deleted from social media, they had also been posted to Mr. Trump’s website and were not taken down for weeks.
By contrast, Mr. Trump made his statement Wednesday to reporters in the hall outside the courtroom, where he typically addresses television cameras. It demonstrated the danger of the gag order to a former president known for spontaneous monologues in which he attacks his enemies.
After Justice Engoron issued the fine, the trial resumed, with Mr. Trump’s lawyers prompting Mr. Cohen to admit that he had lied on past occasions. Soon, another of Mr. Trump’s lawyers, Clifford S. Robert, called for an immediate verdict, given Mr. Cohen’s contradictions. Justice Engoron denied the request, and Mr. Trump slid his chair back and stormed out of the courtroom.
“The judge should end this trial immediately,” he said to reporters as he left.
Nate Schweber contributed reporting.