WASHINGTON — President Joe Biden’s son, Hunter, will plead guilty to federal tax offenses but avoid a full prosecution on a separate gun charge in a deal with the Justice Department that likely spares him time behind bars.

Hunter Biden, 53, will plead guilty to the misdemeanor tax offenses as part of an agreement made public Tuesday. The agreement will also avoid prosecution on a felony charge of illegally possessing a firearm as a drug user, as long as he adheres to conditions agreed to in court. It’s somewhat unusual to resolve a federal criminal case at the same time charges are filed in court but not unheard of.

The deal ends a long-running Justice Department investigation into Biden’s second son, who has acknowledged struggling with addiction following the 2015 death of his brother Beau Biden. It also averts a trial that would have generated days or weeks of distracting headlines for a White House that has strenuously sought to keep its distance from the Justice Department.

While it requires the younger Biden to admit guilt, the deal is narrowly focused on tax and weapons violations rather than anything broader or tied to the Democratic president. Nonetheless, former President Donald Trump and other Republicans continued to try to use the case to shine an unflattering spotlight on the president and to raise questions about the independence of the Biden Justice Department.Trump, challenging President Biden in the 2024 presidential race, likened the agreement to a “mere traffic ticket,” adding, “Our system is BROKEN!”

House Speaker Kevin McCarthy, R-Calif., compared the outcome to the Trump documents case now heading toward federal court and said, “If you are the president’s son, you get a sweetheart deal.”

Republican Florida Gov. Ron DeSantis, another presidential challenger, used the same term.

The White House counsel’s office said simply in a statement that the president and first lady Jill Biden “love their son and support him as he continues to rebuild his life.”

Two people familiar with the investigation said the Justice Department would recommend 24 months of probation for the tax charges, meaning Hunter Biden will not face time in prison. But the decision to go along with any deal is up to the judge. The people were not authorized to speak publicly by name and spoke on the condition of anonymity.

He is to plead guilty to failing to pay more than $100,0000 in taxes on over $1.5 million in income in both 2017 and 2018, charges that carry a maximum possible penalty of a year in prison. The back taxes have since been paid, according to a person familiar with the investigation.

The gun charge states that Hunter Biden possessed a handgun, a Colt Cobra .38 Special, for 11 days in October 2018 despite knowing he was a drug user. The rarely filed count carries a maximum sentence of up to 10 years in prison, but the Justice Department said Hunter Biden had reached a pretrial agreement. This likely means as long as he adheres to the conditions, the case will be wiped from his record.

Christopher Clark, a lawyer for Hunter Biden, said in a statement that it was his understanding that the five-year investigation had now been resolved.

“I know Hunter believes it is important to take responsibility for these mistakes he made during a period of turmoil and addiction in his life,” Clark said. “He looks forward to continuing his recovery and moving forward.”

The agreement comes as the Justice Department pursues perhaps the most consequential case in its history against Trump, the first former president to face federal criminal charges, in relation to accusations of his mishandling classified documents on his Florida estate. It was filed by a special counsel, appointed by Attorney General Merrick Garland to avoid any potential conflict of interest in the Justice Department.

That indictment has nevertheless brought an onslaught of Republican criticism of “politicization” of the Justice Department. Meanwhile, congressional Republicans continue to pursue their own investigations into nearly every facet of Hunter Biden’s business dealings, including foreign payments.

Rep. James Comer, the Republican chairman of the House Oversight Committee, said the younger Biden is “getting away with a slap on the wrist,” despite investigations in Congress that GOP lawmakers say show — but have not yet provided evidence of — a pattern of corruption involving the family’s financial ties.

Democratic Sen. Chris Coons of Delaware, on the other hand, said the case was thoroughly investigated over five years by U.S. Attorney David Weiss, a Delaware prosecutor appointed by Trump.

Resolution of the case, Coons said, “brings to a close a five-year investigation, despite the elaborate conspiracy theories spun by many who believed there would be much more to this.”

The Justice Department investigation into the president’s son burst into public view in December 2020, one month after the 2020 election, when Hunter Biden revealed that he had received a subpoena as part of the department’s scrutiny of his taxes. The subpoena sought information on the younger Biden’s business dealings with a number of entities, including a Ukraine gas company on whose board he sat.

In February 2021, the department sought the resignation of most Trump-era U.S. attorneys, as is customary in a new presidential administration, but made a point of noting that it was leaving Weiss in place as a way to ensure continuity in the probe.