A seven-year-old Facebook message has scuttled a conviction against a man accused by his ex-wife of sexually assaulting and threatening to kill her.

In a decision released Friday, Ontario’s top court said evidence about the message, had it been allowed at trial, could have affected the guilty verdict handed down to the man, who can only be identified as A.B.

“The message was allegedly sent about midpoint in the time frame of the sexual assault allegations,” the Appeal Court said in its decision. “It would not be unfair to say that the message recounted several incidents of sexual activity between the appellant and complainant, and made it clear that the sexual activity was consensual on the complainant’s part.”

Police charged A.B. with sexually assaulting the woman after they had separated and he was living with a new partner. The complainant said her ex had forced himself on her three times, but he insisted the sex was entirely consensual.

To bolster his position, he raised the issue of the Facebook message sent in February 2009, which he said was sent by his former spouse to his new partner and now wife.

At trial in late 2011 in Barrie, Ont., the complainant maintained she had no memory of sending the message, and further testified she didn’t think she had done so. In any event, after the prosecution objected on procedural grounds, Superior Court Justice Guy Di Tomaso ruled against further cross-examination and directed jurors to set aside the evidence they had heard about the post.

The jury convicted A.B., prompting him to turn to the higher court.

Appeal Court submissions show an expert forensic analysis of a computer belonging to A.B.’s new wife turned up the relevant message on her Facebook account. Its date and content had not been manipulated. In addition, the message was found to have come from a computer address associated with the complainant’s brother.

“When interviewed about the results of the investigation, the complainant acknowledged having sent the message,” the Appeal Court noted.

On appeal, A.B. asked to be allowed to introduce the Facebook posting and the results of the forensic analysis as fresh evidence along with his ex-wife’s admission that she had, in fact, sent it. The prosecution did not object.

“The proposed fresh evidence is relevant to a potentially decisive issue — the complainant’s credibility on the issue of consent — which was, after all, the only controverted element of the offence at trial,” the Appeal Court ruled.

“The message had impeachment value as a statement inconsistent with the complainant’s claim of non-consent asserted at trial.”

Both sides in the dispute agreed the new evidence was believable, and, the prosecution acknowledged, could have affected the verdict if jurors had access to the information.

As a result, the Appeal Court agreed to allow the message evidence, quashed the conviction and ordered a new trial. At the request of both prosecution and defence, the court then stayed its new trial order, essentially putting an end to the case.