A federal judge has overturned a decision to discharge a Marine reservist after he was accused of using an unclassified email account to send a warning about an Afghan official.

The ruling on Tuesday, first reported by the Marine Corp Times, comes nearly three years after a Marines Corps board of inquiry recommended that Maj. Jason Brezler be honorably discharged. The decision allowed Brezler to keep his benefits, though he was denied the honor of wearing the uniform

Brezler had warned fellow Marines in August 2012 about an Afghanistan police chief who was linked to the Taliban and was an alleged child molester, days before one of the suspect's alleged victims killed three Marines.

He was accused of sending classified information over an unclassified network because he allegedly used an improper email account to pass on the warning, and later of retaining classified information on his computer.

“This is a stunning rebuke of the fundamentally unjust proceedings to which this decorated Marine was subjected for over three years,” Brezler’s attorney, Michael Bowe, said in a statement.

In his decision, U.S. District Judge Joseph Bianco in New York, wrote that he was not ruling on whether the board of inquiry was an act of retaliation, but that the Navy did not provide Brezler with all relevant documents, which “clearly prevented Major Brezler from fully and fairly litigating his retaliation claims.”

“The Judge correctly found that highly relevant documents and information were withheld from the defense, that the excuses for doing so were ‘completely unsupported’, and that Major Brezler was ‘completely deprived . . . of any meaningful opportunity’ to rebut critical claims," Bowe said in his statement.

The case now goes back to the Secretary of the Navy for a new trial.

Fox News’ Catherine Herridge contributed to this report.