The US army has quashed convictions against a Muslim chaplain initially accused of spying at the US detention camp in Guantanamo Bay in Cuba.
Yee spent two-and-a-half months in custody
It means Captain James Yee - who spent 76 days in custody when the spying allegations were first made - now has a clean military record.
Criminal charges against Captain Yee were dropped last month but he was found guilty of lesser offences.
He was said to have committed adultery and stored porn on his office computer.
For this he received a written reprimand.
He appealed and General James Hill, commander of US Southern Command, has now dismissed the convictions and the reprimand.
But General Hill said it had been necessary to keep Captain Yee in custody.
"While I believe that Chaplain Yee's misconduct was wrong, I do not believe, given the extreme notoriety of his case in the news media, that further stigmatising Chaplain Yee would serve a just and fair purpose," he said.
Captain Yee's lawyer described the case against his client as a "hoax".
"It wouldn't have killed them to admit a mistake," Eugene Fidell said. "Chaplain Yee spent 76 days in pre-trial confinement for no good reason."
Captain Yee might try to sue the government, he added.
Captain Yee was arrested last September as he arrived at a Florida naval base.
In October, he was charged with two counts of failing to obey orders - specifically, for taking classified material to his home.
A month later, he faced fresh charges, including adultery - a crime under US military justice - and storing pornography on a government computer.
A Chinese-American, Capt Yee converted to Islam while serving in Saudi Arabia following the 1991 Gulf war.
His arrest led to concerns about security at the military prison, where more than 600 suspected Taleban and al-Qaeda fighters have been held for over two years.