In a shocking end to a nearly 12-year legal battle, insurance industry legend Maurice “Hank” Greenberg on Friday admitted he “initiated, participated in and approved” two sham transactions in 2000 to prop up AIG’s bottom line.

Greenberg’s admission is part of a settlement of the high-profile fraud suit brought in 2005 by then-Attorney General Eliot Spitzer.

Greenberg, the 91-year-old ex-CEO of AIG, will disgorge $9 million in bonuses he received as a result of the fraud.

“After over a decade of delays, deflections, and denials by Mr. Greenberg, we are pleased that Mr. Greenberg has finally admitted to his role in these fraudulent transactions and will personally pay $9 million to the State of New York,” current Attorney General Eric Schneiderman said in a statement.

Co-defendant Howard Smith, AIG’s former chief financial officer, also settled the case. He will pay back $900,000 in bonuses.

The terms of the settlement were hammered out on Friday afternoon in Manhattan state court before Justice Charles Ramos.

Greenberg was not barred from ever running a public company — something the suit sought — allowing both sides to claim victory.

“Mr. Greenberg did not admit to any fraud at all,” David Boies, Greenberg’s longtime lawyer, told The Post.

Greenberg stepped down as CEO of AIG in 2005 after 35 years atop the insurance giant. He currently runs C.V. Starr, a private insurer.

The $9 million penalty is less than the $16.5 million that Greenberg had earlier offered to settle the suit, Boies said — though the superstar lawyer didn’t disclose other terms of earlier potential deals.

The New York v. Greenberg trial opened last September, but was halted as the two sides tried to hammer out a deal. Lawyers for both Greenberg and Schneiderman have been in mediation for the past month or so.

Greenberg had gotten testy when he was called onto the stand in September and October, needling the prosecutor and refusing to answer questions directly.

At one point, Ramos rebuked the nonagenarian.

“If we don’t want this trial to last a year, we are going to have to get some direct answers,” the judge told Greenberg at one point.

Boies said that he was blindsided Friday afternoon when Schneiderman’s office announced the settlement.

“It is unfortunate that this lawsuit that began with a politically inspired publicity stunt would end with a politically inspired publicity stunt,” Boies said. “That was not a fair release.”

Spitzer’s lawsuit was continued by Andrew Cuomo when he succeeded Spitzer as AG. Schneiderman then carried the legal football — and finally scored with Friday’s settlement.

While Greenberg had given no ground during the trial, he was motivated to settle the charges in order to preserve his legacy and to avoid censure, a source close to the case told The Post.