He added, “I will only say, broadly, there have been conversations about reports, about accuracy, about specific recommendations, all sorts of things, but never a conversation where there was an effort to inhibit the actions of D.O.I. on a specific report.”

Mr. de Blasio could not keep from letting his irritation show, as he was peppered with questions about Mr. Peters. “I’m sorry he has delusions of grandeur in thinking that everything revolves around him,” the mayor said.

If the nasty back-and-forth seemed unusually personal, there is a good reason: Mr. de Blasio and Mr. Peters became friends at least as far back as the 1990s, when they both served on a local school board in the liberal political circles of Park Slope, Brooklyn.

Mr. de Blasio’s political career took off, and by 2013 he was running for mayor, with Mr. Peters as his campaign treasurer. Once elected, Mr. de Blasio named Mr. Peters to lead the Department of Investigation. The choice brought criticism: Could Mr. Peters have the independence to subject his friend’s administration to real scrutiny?

Mr. Peters seemed to answer the question with a series of highly critical reports, exposing shortcomings and mistakes on Mr. de Blasio’s watch, including failures to inspect for lead paint at the Housing Authority and lapses at the Administration for Children’s Services.

But while Mr. de Blasio and his aides may have chafed at the criticism, there was little they could do; firing the investigator who exposed his failings was politically impractical.

But then Mr. Peters overreached. Early this year, he moved to exert his control over the quasi-independent schools commissioner’s office. When the Education Department pushed back, Mr. Peters persisted, ultimately firing the schools investigator, Anastasia Coleman, when she questioned his authority.