Alan McDonald,52, was waiting on the panel to return their verdict on the sexual assault charge at the High Court in Livingston in August 2013.
He pled not guilty to a charge of raping a woman, who cannot be named for legal reasons, at an address in Kirkcaldy, Fife, earlier this year.
Lawyers in the original prosecution discovered that during the jury's considerations, a female jury member left her fellow jurors inside a room to make a telephone call to her child's school.
The law states that jurors are supposed not to leave their room during deliberations for fear that they could talk to other people who could unfairly influence their decision.
When Judge Lady Wise discovered that the woman had made the call, she decided to acquit Mr McDonald, whose address at the time was given as being a prisoner of Perth jail.
But yesterday, at the Court of Criminal Appeal in Edinburgh, judges Lord Carloway, Lord Bracadale and Lady Dorrian, decided to set aside Lady Wise's decision.
They decided that the case should have been deserted - a legal expression meaning that the Crown can decide to bring Mr McDonald to trial sometime in the immediate future.
Now prosecutors are set to try Mr McDonald on the rape charge again.
Yesterday, Lord Carloway said his fellow judge had been wrong to stop Mr McDonald's trial. He said that there was no evidence available to prove that the woman had been subjected to influences which could have affected her decision.
He added: "The decision is incorrect and we recall it."
Prosecutors alleged that Mr McDonald brandished a knife and placed the blade at the woman's throat before repeatedly punching and kicking her. It is then alleged that he raped the woman.
The court heard she had spent 10 to 15 minutes in the corridor speaking to teachers at the school.
Trial judge Lady Wise ruled that the woman's actions were a breach of section 99 (5) of the 1995 Criminal Procedure Scotland Act.