Federal prosecutors have declined to charge former FBI Deputy Director Andrew McCabe — a frequent target of President Trump — closing a probe into whether he committed a crime by giving false information to the feds about his role in leaking to the media, his lawyers said Friday.

The decision ended a criminal investigation that spanned more than a year.

It began with a Justice Department inspector general’s referral that said McCabe repeatedly misled investigators about giving a subordinate the OK to share information with a reporter from the Wall Street Journal for a 2016 article about an FBI probe into the Clinton Foundation.

McCabe has said his 2018 firing just before his planned retirement — for what the Justice Department called “lack of candor” — was politically motivated.

McCabe has denied he intentionally misled anyone, but apologized for lying to agents who spent weeks investigating the source of a leak to the Journal that actually came from him, documents revealed in January.

Shortly before the 2016 election, the Journal reported that an FBI investigation was underway involving then-candidate Hillary Clinton and her family’s foundation.

McCabe in May 2017 denied that he was the source of the leak — but later fessed up, angering bureau investigators who had been spinning their wheels trying to identify the leaker.

The documents, which the FBI released in response to a Freedom of Information Act lawsuit by the government watchdog group Citizens for Responsibility and Ethics in Washington, include transcripts of McCabe’s conversations with investigators, who were frustrated after wasting their time on the probe.

On Aug. 18, 2017, FBI officials grilled McCabe again to try to unravel what they said was “conflicting information” they had gathered about the possible leak to the Journal.

“I need to know from you, did you authorize this article? Were you aware of it? Did you authorize it?” an agent asked McCabe.

The agent then described his response: “And as nice as could be, he said, ‘Yep. Yep I did.’”

The investigator said that “things had suddenly changed 180 degrees with this” after McCabe’s admission, which turned his initial denials into a potential crime.

“In our business, we stop and say, look, now we’re getting into an area for due process,” the agent said.

“I was very careful to say … with all due respect, this is what you told us. This has caused us some kind of, you know, sidetracking here now with some information other people have told us,” said the agent, growing increasingly frustrated.

“I remember saying to him, at, I said, ‘Sir, you understand that we’ve put a lot of work into this based on what you told us,’” the agent said.

“I mean, and I even said, long nights and weekends working on this, trying to find out who amongst your ranks of trusted people would, would do something like that.’ And he kind of just looked down, kind of nodded, and said ‘Yeah I’m sorry.’”

McCabe’s lawyers said in a statement Friday they were told in a phone call and letter that the case was closed and “no charges will be brought against him based on the facts.”

McCabe reacted to the news Friday by slamming the length of the probe while welcoming the outcome.

“To have this horrific black cloud that’s been hanging over me and my family for almost the last two years, to have that finally lifted is just an unbelievable — it’s a relief I’m not sure I can really explain to you adequately,” he told CNN.

“I have to say that as glad as I am that the Justice Department and the DC US Attorney’s Office finally decided to do the right thing today, it’s an absolute disgrace that they took two years and put my family through this experience for two years before they finally drew the obvious conclusion and one they could have drawn a long, long time ago.”

McCabe also criticized Trump for what he called using the Justice Department to go after political enemies.

“As the president’s interest in pursuing his perceived political enemies continued over the last two years, we were getting more and more concerned about where this would end up,” he asserted.

The Justice Department’s inspector general blasted McCabe in April for misleading investigators, but did not include the transcripts in his report.

McCabe’s lawyer has said his story changed because in the first interview, he wasn’t prepared for the question, and that he was soon distracted by Trump’s firing of FBI chief James Comey, whom McCabe replaced as acting director.

McCabe, who said he was confused when first questioned, was fired in March 2018, two days before he was expected to retire, on orders from Trump, who called his ouster a “great day for democracy.”

Lying to the feds is a crime, but McCabe has not been charged.

McCabe sued the Justice Department in August, saying officials had used the inspector general’s conclusions as a pretext to rid the FBI of leaders Trump perceived as biased against him.

In a letter Friday, prosecutors told McCabe’s lawyers that they decided “not to pursue criminal charges against your client” after careful consideration.

“Based on the totality of the circumstances and all of the information known to the government at this time, we consider the matter closed,” said the letter, signed by the chief of the US Attorney’s Office’s public corruption unit.