WASHINGTON — Among tax lawyers, the most invasive type of random audit carried out by the IRS is known, only partly jokingly, as "an autopsy without the benefit of death."

The odds of being selected for that audit in any given year are tiny — out of nearly 153 million individual returns filed for 2017, for example, the IRS targeted about 5,000, or roughly 1 out of 30,600.

One of the few who received a bureaucratic letter with the news that his 2017 return would be under intensive scrutiny was James Comey, who had been fired as FBI director that year by President Donald Trump. Furious over what he saw as Comey's lack of loyalty and his pursuit of the Russia investigation, Trump had continued to rail against him even after his dismissal, accusing him of treason, calling for his prosecution and publicly complaining about the money Comey received for a book after his dismissal.

Comey was informed of the audit in 2019. Two years later, the IRS, still under the leadership of a Trump appointee after President Joe Biden took office, picked about 8,000 returns for the same type of audit Comey had undergone from the 154 million individual returns filed in 2019, or about 1 in 19,250.

Among those who were chosen to have their 2019 returns scrutinized was the man who had been Comey's deputy at the bureau: Andrew McCabe, who served several months as acting FBI director after Comey's firing.

McCabe was later dismissed by the Trump Justice Department after its watchdog accused him of misleading internal FBI investigators. Like Comey, he had come to be perceived as an enemy by Trump, who assailed him, accused him of treason and raised questions about his finances long after pushing for his dismissal and prosecution, a pattern that continued even after Trump lost the 2020 election and began trying to overturn the results.

Comey and McCabe — whose spouses were also audited because both couples filed joint returns — provided the letters initiating their audits to The New York Times. Comey provided the Times with a privacy release allowing the IRS to respond to a Freedom of Information Act request about his case. Neither man knew that the other had been audited until they were told by a reporter for the Times.

The minuscule chances of the two highest-ranking FBI officials — who made some of the most politically consequential law enforcement decisions in a generation — being randomly subjected to a detailed scrub of their tax returns a few years after leaving their posts presents extraordinary questions.

Was it sheer coincidence that two close associates would randomly come under the scrutiny of the same audit program within two years of each other? Did something in their returns increase the chances of their being selected? Could the audits have been connected to criminal investigations pursued by the Trump Justice Department against both men, neither of whom was ever charged?

Or did someone in the federal government or at the IRS — an agency that at times, like under the Nixon administration, was used for political purposes but says it has imposed a range of internal controls intended to thwart anyone from improperly using its powers — corrupt the process?

"Lightning strikes, and that's unusual, and that's what it's like being picked for one of these audits," said John A. Koskinen, the IRS commissioner from 2013 to 2017. "The question is: Does lightning then strike again in the same area? Does it happen? Some people may see that in their lives, but most will not — so you don't need to be an anti-Trumper to look at this and think it's suspicious."

How taxpayers get selected for the program of intensive audits — known as the National Research Program — is closely held. The IRS is prohibited by law from discussing specific cases, further walling off from scrutiny the type of audit Comey and McCabe faced.

IRS Commissioner Chuck Rettig, who was appointed to the post by Trump in 2018, declined to be interviewed about the audits, discussions he may have had with Trump or his political appointees, or how compliance research examinations work. But in a written statement, the agency said he had no role in selecting candidates for audit.

"Commissioner Rettig is not involved in individual audits or taxpayer cases; those are handled by career civil servants," the statement said. "As IRS commissioner, he has never been in contact with the White House — in either administration — on IRS enforcement or individual taxpayer matters. He has been committed to running the IRS in an impartial, unbiased manner from top to bottom."

Pressed on whether the IRS would look into the questions raised by the Comey and McCabe audits, the agency noted in its statement — without referring specifically to their cases — that whenever it learns of allegations of wrongdoing, it reaches out to the inspector general for tax administration in the Treasury Department "for further review."

Asked about the audits, Trump, through a spokesperson, said, "I have no knowledge of this." He went on to point to reports from the Justice Department's inspector general that were critical of Comey and McCabe.

Former IRS officials and tax lawyers said that given the array of reforms imposed on the agency after the Watergate scandal, they believed it would be difficult for a president or an appointee to direct an audit at a political opponent.

But the officials and lawyers said that because Trump repeatedly tried to use the powers of the federal government against his rivals and to overturn the election, and because the IRS conducted an extensive audit on two people whom he routinely pushed to have prosecuted, the tax inspector general or Congress should investigate the circumstances.

Comey's audit, which lasted more than a year, revealed that he and his wife, Patrice Comey, had overpaid their 2017 federal income taxes. They received a $347 refund.

"I don't know whether anything improper happened, but after learning how unusual this audit was and how badly Trump wanted to hurt me during that time, it made sense to try to figure it out," Comey said in a statement. "Maybe it's a coincidence or maybe somebody misused the IRS to get at a political enemy. Given the role Trump wants to continue to play in our country, we should know the answer to that question."

McCabe said that his audit determined that he and his wife, Jill McCabe, owed the federal government a small amount of money, which they paid. He said he now believes the audit has concluded.

"The revenue agent I dealt with was professional and responsive," McCabe said. "Nevertheless, I have significant questions about how or why I was selected for this."

Under the microscope

The audits conducted on Comey, McCabe and their spouses, according to the letters they received from the agency, were carried out under an IRS research program to learn who is — and who is not — paying their taxes.

The agency uses these "compliance research examinations" to determine the tax gap and adjust its dragnets, including a closely guarded formula that is intended to catch tax cheats. The number of audits carried out declined beginning with returns for 2015 because of budget strains before turning up somewhat in 2018 and 2019, the most recent years for which figures are available.

"Your federal income tax return for the year shown above was selected at random for a compliance research examination," the letters to both the Comeys and the McCabes said. "We must examine randomly selected tax returns to better understand tax compliance and improve fairness of the tax system. We'll give you the opportunity to explain any errors we may find during the examination."

In many instances, the agency catches taxpayers who undergo the audits understating their incomes and overstating their deductions, forcing them to pay penalties and interest. Even if a person has done nothing wrong, the process can take months and cost thousands of dollars in accountant fees.

Unlike a typical audit that asks individuals to explain a specific part of their taxes, these audits comb through the full return, forcing taxpayers in some cases to go to great lengths to essentially recreate their finances for the year in question.

Those being audited are often forced to produce bank records, copies of checks, receipts and letters documenting donations to determine whether they are properly reporting income and expenses and are not hiding assets.

In the case of the Comeys, it cost $5,000 in accountant fees. The IRS agent conducting the audit spent at least 50 working hours on it, including meeting face to face with the family's accountant, who drove several hours to meet the agent, according to internal IRS documents produced in response to a Freedom of Information Act request filed by The Times.

Along with having to produce all of his personal financial information, such as brokerage and bank statements, Comey gave the IRS a copy of his family's Christmas card that had a photograph to prove that he had the children he had claimed as dependents.

The audit went so deeply into his finances that his accountant had a back and forth with the agency about how much the Comeys had spent on office supplies purchased more than two years earlier. In an series of documents the accountant provided to the IRS in February 2020, the accountant said that Comey, originally going by memory, had provided far too low an estimate about how much he had spent on them.

"I have attached an invoice to support the cost of the MacBook Air for $1,761," Comey's accountant wrote to the agent in a letter. "He also bought a printer and toner, charged on his AMX, 9/29/17. Mr. Comey has requested a copy of the statement for that month. I will also fax that document to you, when I get it. "A month later, Comey's accountant pushed back on the invasiveness of the audit, likening it to a federal investigation.

"We had a long conversation," the agent wrote in her notes about the call. "He said he couldn't understand this audit, and this is how a fraud case is audited. He also couldn't understand why I requested all bank statements."

The agent said that she explained to the accountant that this was how the audits were conducted if someone like Comey, who had business expenses, did not keep formal books.

Politics and taxes

Comey and McCabe generated ire across partisan lines during their tumultuous tenures at the FBI. Along with being atop Trump's list of enemies, Comey in particular was blamed by many Hillary Clinton supporters for the election of Trump because of how he handled the investigation of her emails during the 2016 election.

The type of audit that the Comeys and McCabes faced was devised to select taxpayers through a statistical software program that groups them by certain undisclosed factors. The system "does not entail employees manually selecting individuals for examination," the agency said.

It is illegal under federal law for anyone in the executive branch — with a few narrow exceptions — to request that the IRS conduct an audit or an investigation of someone's taxes. Any IRS employee receiving such a request is required to report it to the Treasury Department's inspector general for tax administration. Those caught violating the law can be sentenced to up to five years in prison.

Trump, as president, attacked Comey regularly, calling him a "dirty cop" who "should be tried for treason" and "should be arrested on the spot!"

He similarly attacked McCabe, including accusing him of treason. A year before McCabe's audit began, Trump, while still president, publicly asked about McCabe's finances, repeating a long-standing false claim about donations that his wife had received when she ran for Virginia state Senate.

"Was Andy McCabe ever forced to pay back the $700,000 illegally given to him and his wife, for his wife's political campaign, by Crooked Hillary Clinton while Hillary was under FBI investigation, and McCabe was the head of the FBI??? Just askin'?" Trump tweeted in September 2020.

At a minimum, some lawyers said, Trump's public statements about Comey and McCabe, and the fact that the man Trump appointed to the IRS was running it at the time of the audits, could create a perception that the IRS might have been used to carry out a political vendetta.

"When something like that happens, the president's involvement inevitably casts a shadow over an otherwise routine government function and harms the public's confidence in the fair administration of taxes," said Scott D. Michel, a longtime lawyer who specializes in tax disputes.

The audit of the Comeys began in November 2019. The audit of the McCabes started in October 2021, nine months after Trump left office. At the time both audits occurred, the IRS was run by Rettig, whom Biden has allowed to stay on for a term set to expire in November.

During the 2016 election, Rettig, a Los Angeles-based tax lawyer, said that because Trump was under audit, he should "absolutely not" release his tax returns.

The IRS audit of the Comeys' 2017 return started in 2019, three months after Trump blew up at his attorney general at the time, William Barr, over his decision to not charge Comey with a crime for how he handled memos that Comey kept on his interactions with the president. Comey had signed a lucrative book deal in 2017.In the middle of Comey's audit, in January 2020, it was publicly disclosed that he and a longtime friend and adviser, Daniel C. Richman, were under investigation by the Justice Department on suspicion of leaking information related to Comey's decision making in the investigation of Clinton.

Prosecutors were focused on whether the two men had provided classified information to reporters as they tried to provide a rationale for why Comey held a news conference to announce the conclusion of the investigation into Clinton's use of a personal email account. The investigation of Comey and Richman was closed without anyone being charged.

In the days after Comey was fired in May 2017, McCabe took over as acting FBI director and opened investigations into whether Trump had obstructed justice in firing Comey and whether the president, because of his ties to Russia, was a counterintelligence threat to the United States.The Justice Department in 2018 fired McCabe and took away his pension, a move that Trump applauded. The department conducted a wide-ranging investigation into McCabe after his firing.

His audit focused on his 2019 return. That year, with McCabe still a regular target of criticism from Trump, Justice Department prosecutors told McCabe's lawyers that they planned to ask a grand jury to indict him, claiming he had made false statements to internal bureau investigators.

Despite presenting evidence to the grand jury, no charges were ever filed, leading some legal experts to conclude that the grand jury had made the rare move of deciding that there was no basis to charge him.

Shortly after Merrick Garland became attorney general last year in the early months of the Biden administration, Justice Department lawyers began negotiations with McCabe's lawyers to resolve a lawsuit he had brought against the department, claiming that his firing was retaliatory and politically motivated.

In October 2021, the department settled, reinstating McCabe's pension and cleansing his personnel record of his firing. Around that time he received the letter from the IRS beginning the audit. Last month, McCabe was told it had been completed.

This article originally appeared in The New York Times.