Bergdahl faces charges of desertion and endangering fellow soldiers after he disappeared from his base in Afghanistan in June 2009 and was held in captivity by the Taliban until May 2014.
During the 2016 presidential campaign, Trump said Bergdahl "should be shot" for walking off his post. Trump also said that "in the good old days, he would have been executed."
The White House did not respond immediately to a request for comment Saturday on the judge's ruling.
After Trump became president, Bergdahl's lawyers argued the judge should dismiss the charges against their client because of Trump's comments, contending that it would not be possible for Bergdahl to get a fair trial.
But Army Col. Jeffery Nance wrote
Friday that while Trump's comments were "troubling," they did not constitute a sufficient due process violation.
"The comments by Mr. Trump that might be considered pretrial publicity are not so pervasive and unfair as to saturate the community and prevent any trier of fact from being impartial," Nance wrote. He added: "Mr. Trump has said nothing about the accused or his case since August 2016. Under these facts, the court cannot find a due process violation sufficient to make amelioration measures futile."
Eugene Fidell, Bergdahl's chief defense lawyer, told CNN on Saturday that his legal team will take the case to the U.S. Army Court of Criminal Appeals on Monday.
"The military judge's decision was wrong," Fidell added. "Extraordinary relief is required to protect Sgt. Bergdahl's rights to protect the integrity of the military justice system."
Since the officers who could help decide the outcome of Bergdahl's case ultimately report to the President, Fidell argued that Trump's statements constituted "unlawful command influence" -- the idea that anyone with the "mantle of command authority" could wrongly take actions that influence decisions about a defendant.
Trump "has tremendous influence over the entire system," Fidell told CNN.