Bernie Madoff’s longtime accountant is expected to cop a plea deal and admit ​to ​cooking the books on the world’s largest investor fraud, prosecutors said Tuesday.

Assistant US Attorney Matthew Schwartz told Manhattan federal Judge Laura Taylor Swain during a conference that the government is “finalizing” the terms of a plea agreement with Paul Konigsberg, 77, of Greenwich, Conn. Konigsberg​, a long​time member of the arch-schemer’s inner circle​, is expected to formally plead guilty as early as June 24, which is when Taylor scheduled another hearing.

Schwartz added that the accountant would serve as a cooperating witness for the feds under the likely plea dea​l — possibly in future cases against Madoff cohorts or in any retrials or appeals of five employees who were convicted in the scheme.

No other details were given during Tuesday’s hearing.

Both Konigsberg and his lawyer Reed Brodsky declined comment afterwards — and even refused to get on the same elevator with reporters.

Konigsberg helped recruit new investors to Madoff’s Ponzi scheme and even “held a small interest in Madoff Securities International, making him the only person outside the Madoff family to hold an ownership stake,” a law enforcement source said.

He “dictated transaction activity in his customers’ accounts to employees of Madoff Securities,” the source added.

Brodsky has previously claimed the money man and his family members were actually ripped off for more than $10 million through the epic $65 billion Ponzi scheme.

Konigsberg directed the creation of false books and records for Madoff Securities, backdating hundreds of millions of dollars in phony trades for month – if not years – as part of the decades-long investor ripoff, the feds charged.

“In order to keep his scheme hidden for so long, Madoff needed the assistance of certain willing outsiders that could be trusted to handle otherwise suspicious activity,” the indictment says.

Among his assignments was one of Madoff’s “oldest and important customers” who “deposited and withdrew tens of billions” over the years from Madoff Securities, the indictment says. Konigberg was paid $15,000 to $25,000 a month for over a decade specifically handling this client.

The indictment also alleges that Konigsberg through his arrangement with Madoff Securities also arranged for a relative to get a $20,000-a-year no-show job there with full benefits. The relative, listed as an unnamed co-conspirator, pocketed $320,000 plus health benefits from 1992 until 2008 when the firm collapsed.

Konigsberg was a founding partner of Konigsberg Wolf & Company, a midtown accounting firm no longer in operation.

Madoff — who was sentenced to 150 years behind bars — was arrested in Dec. 2008, so Konigsberg’s arrest came only a few months before a 5-year statute of limitations for charges in the Madoff case ended.

Five ex-staffers of Bernie Madoff in March were found guilty of helping the Ponzi monster pull off his epic $17 billion fraud.

But former Madoff operations chief Daniel Bonventre, secretary Annette Bongiorno, account manager Joann Crupi, and computer programmers Jerome O’Hara and George Perez have demanded an acquittal or new trial, claiming they were railroaded by flawed jury deliberations and false testimony from government witnesses.