FRESNO, Calif. — A defendant in a Central California burglary case walked out of a courtroom a free man after a jury mistakenly signed a not-guilty verdict form — only to be killed hours later.

The flabbergasted judge said Wednesday that he had no choice but to order defendant Bobby Lee Pearson to be released from jail because the not-guilty verdict had been put on the record, The Fresno Bee reported.

After it was too late, jurors told the judge they were hung on the charges against Pearson. Prosecutors might have had an opportunity to retry Pearson in the case of a hung jury.

“I can’t believe it,” Superior Court Judge W. Kent Hamlin said after he ordered Pearson to be set free.

Hours later, Pearson was stabbed to death after going to a home to get some clothing and belongings, Fresno police Sgt. James Rios said. He apparently got into a fight early Thursday with his sister’s boyfriend, who Rios says then stabbed him.

The two apparently had a long history of problems. The boyfriend’s name has not been released.

Hamlin said Wednesday that he couldn’t change the verdict form because double jeopardy was already attached.

“This has never happened to me in more than 100 jury trials that I have done,” he said.

Pearson and two co-defendants were accused of burglarizing an apartment last year and stealing a video system and a gun. The homeowner allegedly caught the intruders and wrestled with one of them.

Jurors returned a guilty verdict against Pearson’s co-defendant, Terrel Minniweather, and the mistaken not guilty verdict against Pearson before lunch Wednesday.

Hamlin asked the jury whether that was in fact its verdict against Pearson, and all 12 nodded yes, the Bee reported.

The jurors were then asked to return after lunch for a potential second phase of the trial. The confusion over the verdict against Pearson came to light during lunch, when one juror told court staff that he had voted to find Pearson guilty, said Linden Lindahl, an attorney for Minniweather.

Jurors said they were confused by the forms, one of which was for a guilty verdict and the other for a not guilty verdict.

One juror said there was no form they could sign that indicated the jury was deadlocked.

Lindahl said he was surprised by the jury’s confusion, since the judge “did everything by the book.”