A Manhattan judge on Wednesday ordered Donald J. Trump to the witness stand, questioned him personally, found that his answers were not believable and fined him $10,000.
The judge, Arthur F. Engoron, who is presiding over Mr. Trump’s civil fraud trial, issued the punishment after determining that Mr. Trump had violated an order against discussing court staff when he spoke to reporters earlier in the day.
From the stand, Mr. Trump, wearing a navy suit and curtailing his usual monologue, insisted that his spontaneous comments in a courthouse hallway had been about his former lawyer, Michael D. Cohen, a witness.
They were not, he said, about the judge’s law clerk, Allison Greenfield, whom he had previously attacked on social media. But Mr. Trump testified that he thought Ms. Greenfield was “maybe unfair, and I think she’s very biased against us.”
He left the stand after about three minutes and Justice Engoron made his pronouncement almost immediately afterward.
“I find that the witness is not credible,” he said, and levied the fine as Mr. Trump stared blankly ahead.
The episode was remarkable and wholly unexpected: While Mr. Trump has been voluble in his own defense against accusations that he fraudulently inflated his net worth, 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 early next month in the civil fraud trial and has been criminally indicted four times, it was a discomfiting preview of what may await.
The trial, which stems from a lawsuit filed against Mr. Trump by the New York attorney general, Letitia James, has lasted about three weeks, and Mr. Trump has frequently attended, sitting among his lawyers at the defense table.
The incident that brought him to the stand began Wednesday morning during a break in the proceedings. Speaking to television cameras, Mr. Trump called Justice Engoron partisan, which is allowable under the gag order. But then he added: “with a person who’s very partisan sitting alongside him. Perhaps even much more partisan than he is.”
After the break, the judge cited the comments, and 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 anybody 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 and, after a lunch break, called the hearing.
Mr. Trump trotted to the witness stand and faced the courtroom for his brief questioning. 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, who is chief among the former president’s enemies.
Justice Engoron had already fined Mr. Trump $5,000 last week for comments he made about Ms. Greenfield. That first violation was something of a technicality: Though the comments 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 gag orders to a former president known for spontaneous monologues in which he attacks his enemies. A federal judge overseeing an election interference case against Mr. Trump in Washington also set a gag order, though that has been put on hold while an appeals court weighs its merits.
On Wednesday, Mr. Trump’s testimony and the subsequent fine overshadowed what could otherwise have been a successful day for him, as his lawyers led Mr. Cohen to admit to past lies and to seemingly contradict himself.
Mr. Cohen once worked as a fixer for Mr. Trump. But after breaking with the then-president in 2018, Mr. Cohen testified before Congress that Mr. Trump’s financial statements were filled with fraudulent values calculated to attain his desired overall net worth.
Mr. Cohen repeated those statements on Tuesday, his first day of testimony, when questioned by a lawyer from the attorney general’s office. He also spoke about his involvement in deals in which Mr. Trump’s financial statements were used to showcase the former president’s wealth and financial power.
But on Wednesday, Mr. Trump’s lawyers provoked Mr. Cohen by pointing out his inconsistencies. At one point, Mr. Kise called him a “perjurious witness who has lied to everyone he’s ever spoken to.”
Another lawyer, Alina Habba, suggested that Mr. Cohen had contradicted himself in describing his work on the financial statements. For example, she noted that he said in a deposition that he had worked on “almost every asset,” whereas at the trial on Tuesday, he said that he had worked only on a limited number.
She then moved on to questioning Mr. Cohen’s overall credibility, introducing evidence from before 2018 in which Mr. Cohen praised Mr. Trump, and a text message he had sent about his interest in becoming the White House chief of staff.
By afternoon, Mr. Cohen was flustered.
After Mr. Trump’s stint on the stand, Mr. Cohen returned, tripping over rapid-fire questions from a third Trump lawyer, Clifford S. Robert.
At one point, Mr. Cohen said he did not recall Mr. Trump directing him to inflate the numbers on his financial statements. Mr. Trump threw up his hands as if to proclaim his innocence.
After Mr. Cohen made that admission, Mr. Robert asked Justice Engoron to dismiss the case, a request the judge immediately denied, leading Mr. Trump to push back his chair and storm out of the room.
Mr. Cohen clarified, saying, as he has before, that while Mr. Trump had not explicitly directed him to manipulate the statements, he had conveyed his wishes indirectly.
“Donald Trump speaks like a mob boss,” Mr. Cohen said. “He tells you what he wants without telling you.”
But when Mr. Robert again sought an early verdict, Justice Engoron said that he did not “necessarily consider” Mr. Cohen to be a key witness, adding, “there’s enough evidence in this case to fill this courtroom.”
In a statement, Ms. James echoed that assessment, saying her case was based on “hundreds of thousands of documents and many, many witnesses.”
After court had ended for the day, the former president went after his one-time fixer.
“Their only witness, their chief witness, their only witness, just admitted, number one, he lied,” he told reporters, adding that he did not ask Mr. Cohen to manipulate the figures, and “that should be the end of the case.”
But Mr. Cohen seemed unbowed, or at least unembarrassed. “He will ultimately be held accountable,” he said of Mr. Trump, adding, “That’s what this is all about. It’s accountability.”
Nate Schweber Liset Cruz and Maggie Haberman contributed reporting.