His frequent letters from prison to his older sister soon descended into gibberish, she told NHK, the public broadcaster, and his lawyers say he now shows signs of dementia. It is impossible to know if boxing contributed to his troubles.

By the time his lawyers first told him he was free on Thursday, they said, he seemed almost unable to take in the good news.

“You lie,” he said warily. “I’m finished.”

Mr. Hakamada’s odyssey in the court system began after he retired as a featherweight boxer and went to work at a miso maker in Shizuoka, in central Japan. Several years after he was hired, in 1966, the charred bodies of a manager at the company, his wife and two children were found in what appeared to be a murder and a fire at their house; the house had also been burglarized. More than a month later, the police arrested Mr. Hakamada.

Problems soon arose with the evidence. A pair of bloodstained pants found in a tank of miso paste that prosecutors said belonged to Mr. Hakamada were too small, which his defense team proved when he tried them on in court. But the force of the confession allowed him to be convicted.

The break in the case came recently when the defense team won its argument that DNA testing should be done on the pants and other clothing that was presented as evidence. The testing showed that the blood did not match Mr. Hakamada’s.

In announcing the decision to free him, the presiding judge, Hiroaki Murayama, said in a statement that “the possibility of his innocence has become clear to a respectable degree, and it is unbearably unjust to prolong the defendant’s detention any further.”