Michael Cohen, the former Trump lawyer turned fiery critic, has settled his lawsuit requesting $1.3 million in legal fees from the Trump Organization, Cohen and a company source confirmed to NBC News.

Lawyers for Cohen and the Trump company were in New York State Supreme Court in Manhattan on Friday working on the final terms of the agreement, which were not disclosed.

«This matter has been resolved to the satisfaction of all parties,» Cohen said in a statement.

The Trump Organization declined to comment.

The settlement comes just before the case was scheduled to go to trial. Opening arguments were scheduled to begin Monday, and witnesses, including Donald Trump Jr. and Trump Organization Executive Vice President Alan Garten, were set to testify.

Jury selection had now been completed, with a panel of six men and three women set to hear the case.

Cohen presented the lawsuit in 2019 accusing the Trump Organization of breaching a contractual agreement to «indemnify Mr. Cohen and pay attorneys’ fees and costs incurred by Mr. Cohen in connection with various matters arising out of Mr. Cohen’s work with and on behalf of the Organization and its directors, directors, and officers,» including Donald Trump.

“These matters included multiple congressional hearings, special counsel Robert S. Mueller III’s investigation, and others. As a result of the Trump Organization’s unfounded refusal to meet its indemnification obligations under the severance agreement, Mr. Cohen has incurred millions of dollars in unreimbursed attorneys’ fees and costs, in addition to additional compensable amounts,” the lawsuit states.

The lawsuit says the company paid its fees through May 2018, but stopped after reports it was cooperating with the Mueller investigation.

His testimony before Congress in 2019 about Trump and his company’s business practices led to an investigation by the Manhattan district attorney’s office that resulted in a criminal conviction against the company last year.