Hasan, 42, is accused of killing 13 people and wounding more than two dozen others at Ft. Hood in Texas on Nov. 5, 2009.
Military prosecutors disagreed, as did the judge, Col. Gregory Gross, who ruled that the beard violated the military dress code.
Gross held Hasan in contempt of court for refusing to shave, ordered him removed from the courtroom, and ultimately ordered that he be forcibly shaved. Prosecutors contend that Hasan grew the beard to make it more difficult for witnesses to identify him.
After the U.S. Army Court of Criminal Appeals at Ft. Belvoir, Va., upheld Gross' ruling in October, Hasan appealed to the U.S. Court of Appeals for the Armed Forces, the highest military appellate court.
The top appellate court ruled Monday that military command, not a military judge, has responsibility for grooming standards, and that Gross could no longer appear to be unbiased in Hasan's case.
Gross' order to shave Hasan's beard — and the six counts of contempt he issued to Hasan for failing to shave during pretrial proceedings — were wiped out by the appellate court's ruling.
"Although the military judge here stated that [Hasan's] beard was a 'disruption,' there was insufficient evidence on this record to demonstrate that [Hasan's] beard materially interfered with the proceedings," the unsigned ruling said.
"Taken together," the ruling continued, "the decision to remove [Hasan] from the courtroom, the contempt citations and the decision to order [Hasan's] forcible shaving in the absence of any command action to do the same could leave an objective observer to conclude that the military judge was not impartial."
The appeals court did not specifically rule on Hasan's claim that his beard was protected under freedom of religion.
"Should the next military judge find it necessary to address [Hasan's] beard, such issues should be addressed and litigated anew," the court said.
The ruling also cited an incident in which Gross found what he believed to be feces on the floor of a bathroom and ordered Hasan not to use the bathroom again. Department of Emergency Services staff later said the material was mud that had been tracked in by a guard.
"In light of these rulings, and the military judge's accusations regarding the latrine, it could reasonably appear to an objective observer that the military judge had allowed the proceedings to become a duel of wills between himself and [Hasan] rather than an adjudication of the serious offenses with which [Hasan] is charged," the ruling said.
The appellate court also said the presence of the judge and his family at Ft. Hood on the day of the shootings contributed to its decision to remove Gross from the case, although that would not have been enough by itself to warrant his removal.
If convicted, Hasan could face the death penalty.