Hunter Biden's plea deal with federal prosecutors, which fell apart during his first court appearance in Delaware on Wednesday, would have granted him broad immunity, protecting him from prosecution over a wide range of alleged and potential federal crimes, according to newly released documents.

The son of President Biden was expected to plead guilty to two misdemeanor counts of willful failure to pay federal income tax as part of a deal to avoid jail time on a felony gun charge.

Specifically, the legal arrangement involved both a plea agreement over the tax charges and a related pretrial "diversion agreement" regarding a separate felony charge of possession of a firearm by a person who is an unlawful user of or addicted to a controlled substance. Under the diversion agreement, the government wouldn't charge Hunter Biden with the more serious gun charge if he pleaded guilty to the tax charges.

HUNTER BIDEN PLEADS 'NOT GUILTY' AS PLEA DEAL FALLS APART DURING DELAWARE COURT APPEARANCE

Hunter Biden walks into Federal court dressed in a suit

Hunter Biden arrives at the J. Caleb Boggs Federal Building in Wilmington, Delaware, on Wednesday. (The Image Direct for Fox News Digital)

Judge Maryellen Noreika, who is presiding over the case, did not accept the plea agreement on Wednesday, questioning the deal's constitutionality — namely the diversion measure and the immunity Hunter Biden would receive. Noreika said the diversion agreement might be unconstitutional, which would mean the entire plea deal would be unconstitutional and he would not be getting the immunity he sought.

Ultimately, Hunter Biden pleaded not guilty after the deal collapsed.

In the wake of the courtroom drama, Politico obtained and published the text of both agreements that were part of Hunter Biden's deal. Perhaps most notably, the diversion agreement included a clause granting him broad immunity, in perpetuity, for a range of issues scrutinized by the Justice Department during its yearslong investigation into the first son.

"The United States agrees not to criminally prosecute Biden, outside the terms of this agreement, for any federal crimes encompassed by the attached statement of facts… and the statement of facts attached [to the plea agreement]," the document states. "This agreement does not provide any protection against prosecution for any future conduct by Biden or by any of his affiliated businesses." 

The statement of facts attached to the diversion agreement outlined Hunter Biden's history of often using crack and cocaine — behavior to which Hunter himself has separately admitted — and stated that the first son allegedly lied on a federal form to purchase a firearm by claiming he was not illegally using or addicted to drugs when he actually was.

REPUBLICANS POP OFF OVER HUNTER BIDEN'S REJECTED PLEA DEAL: 'JUSTICE IS COMING'

Hunter Biden Easter Egg Roll

Hunter Biden appears during the White House Easter Egg Roll on the South Lawn of the White House in Washington, D.C., on April 18, 2022. (Demetrius Freeman/The Washington Post via Getty Images)

The statement of facts attached to the separate tax plea agreement outlined Hunter Biden's extensive history of lucrative business dealings in China, Ukraine and elsewhere that have long been under scrutiny. The document also detailed his tax and financial history relevant to the federal charges he's facing. 

Fox News contributor and attorney Sol Wisenberg slammed both Hunter Biden's legal team and federal prosecutors for keeping the broad immunity provision, which he argued could potentially cover "every crime Hunter may have committed" during the relevant time frame, "hidden" in the middle of the diversion agreement.

"This was done by the parties in order that the judge could not accept or reject the broad immunity portion of the overall deal," tweeted Wisenberg. "Totally unprecedented. That's what appropriately set the judge off. She thought it should have been included in the plea agreement, rather than hidden in the diversion agreement. By the way, the transcript shows that the judge didn't even see the key paragraph until shortly before the hearing."

Wisenberg added that both sides can now "try to hammer out an honest deal," adding that if they do the judge will likely accept it, "even though it is a sweetheart deal for Hunter."

CLICK HERE TO GET THE FOX NEWS APP

On Wednesday, prosecutors confirmed Hunter Biden is still under federal investigation as they clashed with his lawyer over whether the now-collapsed plea deal would protect the president's son from potential future charges.