A ringleader of a massive Social Security scam involving retired NYPD and FDNY workers — some of whom lied that they were at Ground Zero to collect benefits — landed a generous plea deal Wednesday.

Ex-cop Joseph Esposito, 70, pleaded guilty in Manhattan Supreme Court to first-degree grand larceny for coaching dozens of ex-cops and firefighters to lie on their disability applications in exchange for kickbacks.

The charge carries a maximum sentence of 25 years, but as part of the agreement, it will be reduced to second-degree grand larceny as long as Esposito fully cooperates with the Manhattan DA’s investigation.

He could then face one-and-a-half to four-and-a-half years behind bars.

“Today, Mr. Esposito accepted responsibility for his role in this disability matter,” said his lawyer, Brian Griffin. “While neither an architect or a mastermind, in his role, his actions crossed and ethical and legal line.”

Esposito did not comment.

More than 120 other people were swept up in the scam, which started 25 years ago, authorities said. Nearly 90 of them have pleaded guilty so far, officials said.

Esposito, who wore a navy pinstriped suit to court, was ordered to pay $733,895.63 in restitution, which had already been seized by authorities from various bank accounts during his January arrest.

Griffin said Esposito plans to fully cooperate with the investigation.

“If called upon by any party, Mr. Esposito will testify to the truth,” the attorney said.

The nearly $22 million scam was allegedly orchestrated by former prosecutor and ex-FBI agent Raymond Lavalle, Thomas Hale, who served as a disability adviser, and John Minvera, who also told applicants to lie in their paperwork, officials said.