Montreal: A Canadian federal judge on Thursday announced his resignation over a controversy sparked when he asked a woman in a sexual assault case why she couldn’t keep her “knees together.”

The Canadian Judicial Council earlier Thursday had asked the Minister of Justice to dismiss Judge Robin Camp, who then issued a statement declaring his resignation.

Camp oversaw a 2014 trial in which he told the woman that “pain and sex sometimes go together.”

He also asked the 19-year-old “why couldn’t you just keep your knees together” to defend herself against her alleged attacker.

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

In its recommendation the council said Camp’s conduct “seriously undermines public confidence in the judiciary.”

“By his statements, the Judge clearly failed to meet high standards Canadians rightfully expect of their judges.”

Since the 1971 creation of the Canadian Judicial Council, just three judges have been forced to resign following the committee’s recommendation.