A judge has been urged to take into account the mental illness history of a man who allegedly raped a woman at knifepoint.
Khateebulla Mirza is accused of breaking into a random woman's apartment at Auburn, in Sydney's western suburbs, and raping the occupant while recording the encounter on his phone.
In the hours before the attack, Mirza is also alleged to have indecently touched a woman's breast in the inner-west suburb of Marrickville.
A month earlier, the 38-year-old allegedly touched a woman on the backside outside a building in Zetland, in the city's inner-south.
Mirza pleaded not guilty to eight charges, including sexual touching without consent, aggravated sexual intercourse without consent and assault.
In closing arguments on Wednesday afternoon, crown prosecutor Caroline Dobraszczyk told the court that the acts had been proven beyond reasonable doubt. However, the court must decide if he was criminally responsible at the time.
"I can say that this case is not as clear-cut as maybe other cases," she told the judge-alone trial in Sydney's Downing Centre District Court.
In his closing submissions, Mirza's barrister Bill Neild SC argued the defence of mental impairment and urged the judge to take into account the historical evidence of his mental illness.
Across two days, Judge Ian Bourke heard from two expert witnesses who met with Mirza in the months following the alleged offending.
Crown witness and forensic psychiatrist David Greenberg told the court the 38-year-old truly believed he was being programmed to commit offences.
"All three offences in his mind were morally justified because he was in a game being programmed, that controlled his behaviour was justified even though it was legally wrong," he said.
Ms Dobraszczyk pressed Professor Greenberg on his assessments of Mirza from two sessions.
"You are firmly of the opinion ... that he didn't understand the acts?" she asked.
"That is correct," Prof Greenberg said.
Another forensic psychiatrist, defence witness Adam Martin, previously told the court that Mirza was mentally impaired at the time of the incidents.
Dr Martin said Mirza was experiencing "delusional beliefs" that he was trapped in a video game.
Judge Bourke adjourned the case with a decision set to be made on Tuesday.
1800 RESPECT (1800 737 732)
National Sexual Abuse and Redress Support Service 1800 211 028
Lifeline 13 11 14
beyondblue 1300 22 4636