Fired FBI Director James B. Comey went to bat for Andrew McCabe on Jan. 29, tweeting that his onetime deputy director “stood tall when small people were trying to tear down an institution we all depend on.”

But inside the Justice Department last year, the two men, who had run the bureau as a team before both were fired nearly a year apart, were locked in a bitter dispute over who was telling the truth. They provided “starkly conflicting accounts” about a pivotal private meeting that helped lead to Mr. McCabe’s firing, an investigation has found.

Mr. McCabe’s attorney basically accused Mr. Comey of lying, or at least of lacking credibility, in testifying about a conversation the two had over a leak to The Wall Street Journal. The attorney said the Justice Department inspector general was anointing Mr. Comey as a “white knight carefully guarding FBI information while overlooking that Mr. McCabe’s account is more credible.”

Mr. McCabe accused Mr. Comey of denying the deputy’s version as a way to distance himself politically from the Journal leak.

Mr. Comey strenuously disputed Mr. McCabe’s testimony that he, the director, thought the leak was a good idea, according to a Justice Department inspector general’s report released Friday.

Inspector General Michael E. Horowitz ultimately sided with Mr. Comey as the truth teller.

The backdrop: According to the inspector general’s 35-page report, Mr. McCabe orchestrated the leak to The Journal that disclosed a phone call he had with a senior Obama Justice Department official. The unidentified official wanted the FBI to slow down an investigation into the Clinton Foundation.

Mr. McCabe instructed his special counsel in October 2016 to anonymously tell the Journal reporter that he, Mr. McCabe, stood up to Justice.

At the time, Mr. McCabe was under intense pressure after The Journal disclosed that his wife, as a Democratic candidate for Virginia’s state Senate in 2015, received nearly $500,000 from a political action committee run by then-Virginia Gov. Terry McAuliffe. He is an integral part of the Bill and Hillary Clinton political team.

The appearance of a conflict of interest prompted Mr. Comey to kick Mr. McCabe off a conference call in which aides were discussing the FBI investigation into Hillary Clinton’s use of an at-home email server to handle sensitive classified information when she was secretary of state.

The McCabe-engineered leak violated FBI rules forbidding the disclosure of an ongoing criminal investigation — in this case the Clintons’ billion-dollar charity that has taken millions of dollars from foreign donors.

Mr. Horowitz, the inspector general, concluded that Mr. McCabe lied four times (in FBI parlance, he “lacked candor”), three times under oath to investigators and once to Mr. Comey.

Attorney General Jeff Sessions fired Mr. McCabe on March 16, days short of full retirement pay, based on a recommendation from the FBI’s office of professional responsibility. President Trump fired Mr. Comey in May 2017.

The McCabe leak investigation began with FBI agents and then shifted to Mr. Horowitz at Justice.

Mr. McCabe at one point threw investigators off course by saying he had no idea where the leak came from while suggesting the guilty parties were officials who heard about his phone call with the senior Justice Department official.

The inspector general’s agents later complained that he had forced them to work nights and weekends to run down those supposed officials when the actual leakers were Mr. McCabe and his special counsel. The inspector general’s report said the investigation did not find one FBI official, besides Mr. McCabe and his special counsel, who knew about the phone call.

Perhaps the most interesting aspect of Mr. Horowitz’s detailed report was the Comey-McCabe standoff.

The dispute centered on the two privately discussing the Journal leak in Mr. Comey’s office on Oct. 31, 2016, the day after the story appeared. The story contained the tidbits of the Aug. 12 McCabe-Justice phone call and the fact that there was an investigation into the Clinton Foundation.

‘Small people’

According to Mr. Comey, Mr. McCabe denied to him that he had any role in the leak.

“Comey and McCabe gave starkly conflicting accounts of this conservation,” the inspector general’s report said.

“McCabe asserted that he explicitly told Comey during that conversation that he authorized the disclosure and that Comey agreed it was a ‘good’ idea,” the report said.

Conversely, “Comey described how McCabe gave Comey the impression that McCabe had not authorized the disclosure about the [Aug. 12] call, was not involved in the disclosure and did not know how it happened.”

Mr. Comey testified that weighty investigations, such as the Clinton Foundation, would be disclosed officially only after high-level Justice-FBI discussions and never via an anonymous leak.

For example, Mr. Comey publicly confirmed the Trump-Russia collusion investigation at a March 20, 2017, House committee hearing and noted that he had been authorized to do so.

“We found it highly improbable that Comey would have been approving of a decision by McCabe to disclose to a reporter, on background, information essentially confirming the existence of an FBI investigation that Comey himself had refused to confirm when testifying before Congress,” the inspector general said.

The inspector general squarely sided with Mr. Comey and concluded that Mr. McCabe had lied to him.

“As we note in the report, none of the circumstantial evidence supports McCabe’s claim, while the overwhelming weight of the circumstantial evidence support’s Comey’s recollection,” Mr. Horowitz said. “In his submission, McCabe presented no evidence to corroborate his version of events. Instead, McCabe focuses entirely on attacking the credibility of Comey’s recollection.”

The inspector general concluded that Mr. McCabe’s motives were not pure, that he wanted to counter a narrative that he was biased in favor of the Clintons.

“McCabe’s disclosure was an attempt to make himself look good by making senior department leadership, specifically the Principal Associate Deputy Attorney General, look bad,” the report said.

Even though Mr. McCabe and Mr. Comey took starkly different positions against each other, the former director voiced unqualified support for his former deputy this winter after news of the inspector general’s pending conclusions broke.

Mr. Comey tweeted, “Special Agent Andrew McCabe stood tall over the last 8 months, when small people were trying to tear down an institution we all depend on. He served with distinction for two decades. I wish Andy well.”

By “small people,” Mr. Comey may have been referring to Republicans on the House Permanent Select Committee on Intelligence.

Led by Chairman Devin Nunes of California, the committee’s Republicans forced the Justice Department to reveal that the FBI had relied on the discredited Christopher Steele dossier to persuade a judge to authorize wiretaps on Trump campaign volunteer Carter Page.

Mr. Nunes accused the FBI of misleading the judge by failing to disclose that the dossier was financed by the Democratic National Committee and the Hillary Clinton campaign. Those funding sources were discovered by Mr. Nunes via subpoenas for bank records of the investigative firm Fusion GPS, which hired Mr. Steele.

In another FBI misstep, special counsel Robert Mueller fired his lead FBI agent, Peter Strzok, after learning of text messages between Mr. Strzok and his lover, FBI lawyer Lisa Page, that showed bias against Mr. Trump.

Mr. Comey’s book, “A Higher Loyalty,” will be released Tuesday and will have plenty of attacks on Mr. Trump.

Mr. McCabe’s dismissal has elevated him to hero status by liberals and Democrats, some of whom promised to hire him for enough days to earn a full 20-year retirement.

Mr. McCabe’s GoFundMe page raised more than $500,000 for legal expenses.