(CNN) -- President Donald Trump's former personal attorney, Michael Cohen, sued the Trump Organization on Thursday, saying that after Cohen began cooperating with federal investigators, the company failed to fulfill its contractual obligations to indemnify him or pay his legal bills relating to his work for the firm.

Cohen -- an executive at the Trump Organization until early 2017, when he left that post to work as Trump's personal attorney -- alleged in the lawsuit the company is obligated to pay both his legal bills, which now total at least $1.9 million, and another $1.9 million he owes as part of a criminal sentence he received late last year.

Cohen incurred legal bills from several law firms starting in 2017, when he began to face multiple inquiries, including congressional hearings, civil lawsuits, the investigation from special counsel Robert Mueller and, by 2018, a criminal probe from the Manhattan US Attorney's office.

In July 2017, according to the lawsuit filed in the New York state Supreme Court, the Trump Organization agreed to indemnify Cohen and to pay his attorneys' fees and costs in connection with related investigations.

"The Trump Organization and Mr. Cohen were proceeding pursuant to a 'joint defense' at that time with respect to the Investigations and other matters," the lawsuit says.

Cohen said the company initially fulfilled its obligation, paying $137,460 to a firm that initially represented him, McDermott Will & Emery LLP, in October 2017, which amounted to half of the invoices he had received. The Trump Organization then promised that the Trump presidential campaign would pay the remainder the following day, according to the lawsuit.

The company then continued to pay "all or part" of McDermott's fees and costs through May 2018, according to the lawsuit. At that point, Cohen himself was facing a criminal investigation by the Manhattan US Attorney's office, but he hadn't yet spoken to investigators, according to court filings.

Through that June, the Trump Organization continued to pay his legal bills to McDermott, which totaled more than $1.7 million.

That month, however, while Cohen was facing multiple criminal probes, he "began telling friends and family that he was willing to cooperate with the Special Counsel and federal prosecutors in connection with the (Southern District of New York) Investigation," the lawsuit says. "The expectation that Mr. Cohen would cooperate with the Special Counsel, following the departure of McDermott as his counsel, was widely reported that month."

And that month, the company stopped paying the bills Cohen incurred at the McDermott firm, according to the lawsuit.

Over the following weeks and months, which included a period during which Cohen spoke multiple times to federal investigators and pleaded guilty to eight felonies in which he implicated Trump, the President publicly distanced himself from his former attorney. That evolution culminated in a December tweet by Trump, saying, "Remember, Michael Cohen only became a 'Rat' after the FBI did something which was absolutely unthinkable & unheard of until the Witch Hunt was illegally started. They BROKE INTO AN ATTORNEY'S OFFICE!"

Alan Garten, a lawyer for Trump Organization, declined to comment on the lawsuit.

The lawsuit alleges that "as a result of the Trump Organization's wrongful refusal to pay McDermott's invoices under the indemnification agreement, McDermott ultimately withdrew from its representation of Mr. Cohen."

"McDermott's withdrawal prejudiced Mr. Cohen's ability to respond to the Mueller investigation, the SDNY Investigation, and other matters," the lawsuit says. According to Cohen, the Trump Organization owes $1,037,868.87 to McDermott for its representation of Cohen.

After McDermott stopped working with Cohen, he hired new lawyers, including those from the firms Petrillo Klein & Boxer LLP; Blakely Law Group; Davis Goldberg & Galper PLLC; and Monico & Spevack, and the bills he has incurred through January 2019 total more than $1.9 million, according to the lawsuit.

In addition, Cohen alleges, the Trump Organization is obligated by its indemnification agreement to pay the $1.9 million he has been ordered to pay or forfeit as part of the criminal sentence he received after pleading guilty in the Manhattan US Attorney's case.