Ontario's top court has ordered a new trial for a Toronto man convicted of sexually assaulting a friend after an out-of-town wedding, saying the judge who oversaw the case erred in his instructions to the jury.

Paul Chafe was found guilty in 2017 in connection with an incident that took place five years earlier in Kitchener, Ont., where he, his girlfriend and a mutual longtime friend had gone for a wedding.

The three were sharing a suite in a Conestoga College residence hall but had separate rooms, with the couple in one and the friend in the other.

The complainant, who cannot be identified, alleged she was sexually assaulted in her room during the night after the group and several other wedding guests returned to the residence hall following the reception.

She identified Chafe as the man she had seen masturbating in her doorway, and believed he was also the one who had allegedly done so in her bed later that night.

In a decision released this month, the Court of Appeal for Ontario found the judge failed to properly caution jurors on the dangers inherent to eyewitness identification and failed to give guidance on how to assess evidence related to Chafe's reaction to the allegations.

"The case against the appellant rested entirely on identity," the Appeal Court said. "The identity rested entirely on the complainant's recognition of the appellant as the man in the doorway."

The trial judge initially gave the correct instructions on this issue, the court said.

"He cautioned about guarding against honest but mistaken belief. He referred to the frailties in the complainant's evidence: she had just woken up; she had consumed a lot of alcohol; she saw the man for three-four seconds; she initially told the police the man was wearing the suit he wore to the wedding," it wrote.

However, the trial judge mistakenly told jurors that "identification of a known person is different than identification of a stranger," which negated his earlier instructions, the Appeal Court said.

The error was "compounded" when the judge added that the complainant knew Chafe was the only man staying in the suite that night, which was "misleading," the court said.

"While the appellant may have been the only male 'staying' in the particular suite, there was evidence that other males had come to the residence after the wedding to continue the party and were occasionally wandering around," it said.

"The judge's comment artificially bolstered the identification evidence by incorrectly implying that the man in the doorway had to be the appellant because he was the only male staying in the suite."

The judge also erred in not instructing the jury on how to handle evidence regarding Chafe's response when his girlfriend confronted him with the allegations, the Appeal Court said.

His girlfriend testified that she confronted him immediately after hearing from their friend, saying she knew what he had done, the decision said. She couldn't recall his exact response but said it was, broadly, that he couldn't remember, the document said.

She spoke to him on the phone in the following months and asked if he had "grabbed" the complainant and though she couldn't remember his exact words, she was left with the impression that he was acknowledging the allegation, the document said.

The Crown stressed in its closing arguments that Chafe had not denied the allegations, relying instead on his lack of memory, the decision said.

"In fact, the appellant could not deny 'it' because he did not know what 'it' was," the Appeal Court said.

"The appellant was given no details about the allegations because (his girlfriend) did not know the details of the allegations. And (his girlfriend) did not know the details of the allegations because the complainant had not told her. She just had the impression that the appellant had been sexually inappropriate."

It was incumbent on the judge to warn jurors about the dangers of relying on this evidence, the court said.

"This would include an instruction that they should place no weight on his response to an accusation when he was given no details; that there is no 'normal' way for a person to respond when faced with an accusation of wrongdoing; that failure to recall is not an admission; and that they should not rely on (his girlfriend)'s 'impression' of what his reaction meant in the face of his explanations," it said.

"Without these directions, the jury was left with the suggestion that the appellant had confessed to the charge."

As a result of the errors, Chafe's right to a fair trial was compromised, the Appeal Court said.