A Canadian judge who asked a woman why she couldn't keep her knees together after she alleged sexual assault in a trial said on Thursday he was resigning from the bench.

Justice Robin Camp said in a statement released by his lawyer that he would resign effective from Friday.

“I would like to express my sincere apology to everyone who was hurt by my comments,” he said in a statement.

The Canadian Judicial Council said in a review released on Thursday that Mr Camp's conduct during a 2014 sex assault trial in Calgary was so "manifestly and profoundly destructive" towards judicial impartiality that he could not remain in office.

Had Mr Camp not resigned of his own accord he could have been the first federal judge to be removed by Canada's Parliament.

According to transcripts, Mr Camp repeatedly referred to the 19-year-old complainant as the "accused" during the trial, and said in his ruling she "hasn't explained why she allowed the sex to happen if she didn't want it."

“Why couldn’t you just keep your knees together?” Mr Camp asked her, adding that "pain and sex sometimes go together".

Mr Camp acquitted the accused but his decision was overturned on appeal. The defendant, Alexander Wagar, was acquitted in January following a second trial.