Navy SEAL Eddie Gallagher was released from pre-trial confinement late Thursday after a contentious pre-trial hearing in which Navy prosecutors’ alleged misconduct came under serious scrutiny.

Gallagher’s release comes just a few hours after he celebrated his birthday with family in confinement.

Sources familiar with the matter tell Breitbart News that the defense team for Gallagher, who is charged with war crimes in the death of an ISIS fighter in Iraq, made a series of motions in Thursday’s hearing to push for charges to be dismissed against him due to prosecutorial misconduct. Among other things, sources familiar with the matter say, the prosecution administered a lie detector test to Gallagher–which he passed–and did not disclose that to the court or to the defense. In addition, the prosecution spied on the defense and on the news media through email tracking programs.

The incident for which Gallagher is charged has come under question in recent weeks, as Breitbart News has reported extensively. A video of the actual incident was made available to members of Congress through Rep. Duncan Hunter (R-CA), who said the video proves that Gallagher was actually attempting to save the life of the ISIS fighter he is charged with killing, but rather rendering emergency field medical care to the fighter.

What happened in Mosul, Iraq, is that Gallagher’s unit was fighting with an ISIS cell holed up in a building for hours. After some time, the U.S. military used a hellfire missile to blow up the compound. The sole surviving ISIS fighter came out of the building, wounded, and was taken into custody by Iraqi forces. Several hours later, the ISIS fighter was transferred to the custody of the U.S. forces under Gallagher. Badly wounded, the ISIS fighter needed life-saving medical care. Gallagher, who is trained in emergency field medicine, per exculpatory photographs and video provided to members of Congress–and in the possession of prosecutors from day one–attempted an emergency procedure to try to save the man’s life so they could retrieve valuable intelligence from him. The ISIS fighter died.

Later, in the United States, Gallagher was charged with war crimes as a result of the incident. The Navy prosecutors bringing the case against him raided his home in the middle of the night, and Gallagher has been in federal custody for months since. At first, the facility he was kept in had substandard conditions, and news reports on the matter caught the attention of President Donald Trump, who ordered him moved to a safer facility.

The president’s lawyer Marc Mukasey, in a personal capacity, took up the case, and rumors circulated about whether President Trump might pardon Gallagher before the trial. Trump’s 2016 general election opponent, Democrat Hillary Rodham Clinton, bashed Trump for considering pardoning Gallagher:

But then news came out that the prosecution spied illicitly on the defense and on the news media, specifically the Navy Times. The trial was set to begin this week, but in the wake of these and other revelations, it has been repeatedly postponed. This week, pre-trial hearings were set starting on Wednesday. Those were delayed until Thursday, and now after a day full of embarrassing moments for the prosecution per sources presentm, the judge ordered Gallagher released. The pre-trial hearing with defense motions, including efforts to dismiss the case entirely, is set to resume on Friday, but now Gallagher is free from custody for the first time since this all began.

Andrea Gallagher, Eddie’s wife, has compared what the government did to her husband and her family to domestic terrorism. As Breitbart News reported for a Memorial Day weekend radio special:

“We’ve gone through eight deployments as a family, raising three children and really sacrificing my husband to the war on terror was our goal of achieving victory over what happened on 9/11,” Andrea Gallagher said in a Breitbart News radio exclusive hourlong special on her husband’s story that aired on Saturday and Sunday this weekend.

“Over the years, we let him go time and time again. Never in a million years would I have foreseen that on his very last combat trip, which was to Mosul where he was previously awarded number one chief and number one platoon, he was tasked with clearing Mosul of ISIS, which he succeeded in, and then over a year later he would come back to a disgruntled group of individuals who, once they found out he was yet again being elevated for his twilight tour to a very coveted billet where he would be training every Navy SEAL on the West Coast, and once they found out they were going to be under him again, they set up a plot to take him down. Now, it never would have occurred to them, I don’t think, that it could have gone this far,” she said.

Now, Andrea Gallagher says her family has been put through a “horrific nightmare” that she called “domestic terror” at the hands of NCIS Naval prosecutors who brought war crimes charges against her husband and for which he has been awaiting trial.

“But our family has been entrapped in what I can only call a horrific nightmare, and it definitely has been encompassed by some domestic terror unleashed on our family by NCIS who picked up the case in April of 2018,” she said. “They raided our home, pulled out our kids at gunpoint into the streets in their underwear by June. So, less than 60 days on basically just rumors, lies, and hearsay is how they cobbled together this case. Ever since, we have suffered. My husband was taken out of a TBI clinic on 9/11. He was thrown in jail and he actually was in jail for seven and a half months before President Trump intervened in March.”

Rep. Hunter, in that same radio special, said that the reason this happened is political correctness infecting the military community.

“It happens over time when you’re in an 18-year war in Afghanistan, a 16-year war in Iraq, here’s what happens,” Rep. Hunter said on Breitbart News radio. “You got about one percent of the U.S. military is actually out fighting. The other 99 percent are back here behind the gates safe and sound. That means the people that run the military right now, mostly Obama guys because the people that are in power now were put into power by him four years ago, six year ago, eight years ago, those guys are now more political—those admirals and generals—and run by the lawyers and bureaucrats, than politicians are. That’s what’s happened. You have the very few select guys who go outside the city gates and do bad things to bad people, and carry our U.S. flag to foreign soil, while the other 99 percent of folks sit back here and try to judge those fighters, those warriors who fight on our behalf—on the American people’s behalf. The people sitting back here, the bureaucrats, the lawyers, and the politicians, try to judge those warriors in the context of our freedom, safety, and security and rules of law back here at home. It’s happened over a period of time. It didn’t happen all of a sudden.”