But the position of Mr. Trump and his legal team appeared to soften soon after his election victory on Nov. 8. At a hearing last week, Daniel Petrocelli, a lawyer for Mr. Trump, expressed interest in moving toward a settlement. Meanwhile, Mr. Trump’s lawyers were seeking to delay the trial in one of the California cases until after his inauguration on Jan. 20, while also requesting that he be allowed to testify on video.

At a hearing on the case in San Diego on Friday, Mr. Petrocelli said Mr. Trump had settled the case “without an acknowledgment of fault or liability.”

The judge overseeing the two California cases, Gonzalo Curiel, was thrust into the limelight of the campaign in May when Mr. Trump spent several minutes at a rally denouncing the judge’s decisions in the case, calling him a “hater” and questioning his impartiality because of his Mexican heritage.

After he faced days of criticism for his remarks on the judge, Mr. Trump released a statement saying his words had been “misconstrued as a categorical attack against people of Mexican heritage.” He also asserted that he was justified in questioning the fairness of his trial, given various rulings in the case that went against him. Still, he concluded, “we will win this case!”

Judge Curiel said in court Friday that he hoped that the settlement agreement — and the end of the presidential campaign — would begin “a healing process that this country very sorely needs.”

Under the agreement, Mr. Trump will pay $21 million to settle the two California class-action suits and $4 million to settle with the New York attorney general. The lawyers for the plaintiffs waived their attorneys’ fees. The deal still has to be approved in court, which could take months.