The Supreme Court in Brisbane was told on Monday 22-year-old Dirk Antoni Van Den Brand had tried to suffocate the 37-year-old woman at her Brisbane home in September last year.
Prosecutor Michael Lahane said Van Den Brand slipped the plastic bag over the woman's head and tightened his hands around her neck as she escorted him to the door.
Mr Lahane said his plan was to render her unconscious so he could steal back the $100 he had paid for sex just minutes earlier.
The court was told his plan was foiled when she screamed for her boyfriend, who emerged from another room and held Van Den Brand until police arrived.
Mr Lahane said Van Den Brand told police he had arrived at the woman's apartment with sex aids in the plastic bag.
He said as he was going to leave he had simply been holding the open plastic bag at her head level, and the woman had turned and accidentally walked into it.
Van Den Brand said the woman panicked and struggled, and then he was unfairly assaulted by her boyfriend.
Defence council David Kent said his client had not been living in Brisbane for long when the incident occurred, and that he had been a shy person who had struggled to make friends.
He had visited the same prostitute twice before, on one occasion pushing her in an attempt to get her to lie down, even though he had no money.
Justice James Douglas rejected Mr Kent's submission for Van Den Brand's immediate release, saying the offence was a "very serious'' one that required a deterrent sentence.
He sentenced Van Den Brand to two years' jail on a charge of disabling to commit an indictable offence and ordered he be released on parole in June next year.