The beginning of the end for Forrest Claypool came nearly two years ago.

It was just months after Mayor Rahm Emanuel had chosen his longtime friend and top aide to replace Chicago Public Schools CEO Barbara Byrd-Bennett, who left in a bribery scandal that sent her to prison.

Like so many stories of public-servant shenanigans in Chicago, this one started with a taxpayer-funded deal involving a friend of the boss. It ended Friday with Claypool, 60, resigning his $250,000-a-year job, acknowledging “stupid mistakes” that unsparingly were laid bare by an ethics investigation of his good friend, top CPS lawyer Ronald Marmer.

UNDER FIRE: Claypool quits after inspector general’s report; Jackson takes over
NEW BOSS: How Janice Jackson went from CPS student to the district’s CEO
WATCHDOGS: Report details how Claypool tried to block ethics probe
EDITORIAL: Best thing for CPS was for Claypool to leave

Shortly after taking the CEO’s job at the schools in 2015, Claypool arranged for the Chicago Board of Education to hire Marmer as general counsel.

Claypool and Marmer first worked together more than three decades earlier, when Claypool landed his first job after passing the bar, with the law firm Jenner & Block.

Claypool didn’t stay at the firm for long, quickly moving into what would be a long career in the public sector. He held high-ranking posts at almost every other level of Chicago government before landing at CPS.

With Marmer at CPS, Claypool set about filing a civil rights lawsuit against the state to get more money for Chicago’s schools.

Claypool wanted CPS to hire Jenner & Block to handle the case. The firm’s lawyer who signed the deal with the Claypool administration was Randall Mehrberg. He’d been the top lawyer for the Chicago Park District in the 1990s, when Claypool was parks chief under then-mayor Richard M. Daley. Mehrberg later gave tens of thousands of dollars to Claypool’s political campaigns.

Mehrberg also was a volunteer adviser to Claypool in the mayor’s office when Claypool was Emanuel’s chief of staff, in 2015.

After Claypool went to CPS, Mehberg left City Hall, too. He went to work at Jenner & Block, where he began focusing on what would be CPS’ case against the state.

On March 1, 2016, Mehrberg sent a message to Claypool from his new job: “I started at Jenner today. I will get the file opened.”

Two days later, the firm started billing CPS, records show.

Claypool wanted Marmer to supervise the Jenner & Block lawyers working for the cash-strapped public schools. And Marmer did, the Chicago Sun-Times has reported, citing internal emails.

By April 2016, Mehrberg had sent Marmer copies of a draft lawsuit, and Marmer reported to Claypool on the case’s progress. Also that month, Mehrberg emailed Claypool to tell him he and Marmer had a “good conversation” about the planned suit.

“Great,” Claypool replied.

But there was one problem. Under the school system’s ethics code, officials can’t supervise the work of any CPS contractor with whom they have a “business relationship.” And Marmer was getting a $1 million severance package from Jenner & Block, in five $200,000 yearly installments through 2018.

Four in-house lawyers agreed Marmer shouldn’t be supervising his old employers. Two outside lawyers consulted in the spring of 2016 agreed.

But Claypool scurried to find a seventh — this time favorable — legal opinion from political supporter J. Timothy Eaton in June 2016.

By that time — May 12, 2016 — the Sun-Times had filed the first in a series of Freedom of Information Act requests for CPS records on the deal.

CPS didn’t comply with the requests until after the school board approved the deal with Jenner & Block in late July 2016. A Sun-Times report on the issue prompted CPS Inspector General Nicholas Schuler to begin investigating.

On Tuesday — 16 months later — Schuler handed Board of Ed members a searing report that called for Claypool’s firing, saying the CEO lied repeatedly to him in a “full-blown cover-up” of a clear ethical violation by Marmer.

Schuler wrote that Claypool refused to pay one of the outside lawyers and got the other to alter the work description on his firm’s invoices, all to hide what was going on.

“None of this should have happened,” Schuler said.