NEW YORK >> Allen H. Weisselberg, one of Donald Trump’s most trusted lieutenants, stood before a judge in a lower Manhattan courtroom Thursday and admitted that he had conspired with the former president’s company to commit numerous crimes.

Weisselberg’s guilty plea, which followed more than a year of the Manhattan district attorney’s office pressuring him to cooperate in a broader investigation of Trump, painted a damning picture of the beleaguered company, which now faces significant financial penalties if it loses its own trial on similar charges.

But for prosecutors who have long sought to indict Trump, Thursday’s hearing was something of a consolation prize. Weisselberg refused to turn on Trump himself, something prosecutors had hoped he would do since they charged him with 15 felonies last July.

Under the plea deal, Weisselberg must pay nearly $2 million in taxes, penalties and interest after accepting lavish off-the-books perks from Trump and his company, including leased Mercedes-Benzes, an apartment on Manhattan’s Upper West Side and private school tuition for his grandchildren.

He also must point the finger at his longtime employer, the Trump Organization, at its trial in October. In exchange, Weisselberg, who was facing years in prison, is likely to receive a five-month jail sentence, and with time credited for good behavior, he might serve as little as 100 days.

The deal emerged after weeks of pitched back-and-forth negotiations. They culminated in a crucial meeting Monday, Weisselberg’s 75th birthday, when his lawyers gathered with prosecutors in the judge’s chambers, according to people with knowledge of the matter.

Weisselberg’s lawyers, Nicholas A. Gravante Jr. and Mary E. Mulligan, pressed for leniency, emphasizing their client’s age, frail health and past service in the National Guard and arguing the DA’s demand for a six-month jail term was excessive.

The judge had previously warned that Weisselberg’s only chance for probation was cooperating with the broader investigation into Trump’s business practices. With that off the table, he proposed a compromise: Over the objections of the district attorney’s office, the judge would agree to the five-month sentence.

An examination of how the deal took shape, based on interviews with a half-dozen people knowledgeable about the plea negotiations, underscores Weisselberg’s bottom line: He would not betray Trump. For now at least, that unflinching loyalty to a family he has served for nearly a half-century has helped stymie the larger effort to indict the former president.