The victim, who cannot be named for legal reasons, was sexually assaulted by Dale Everard after a night out with his girlfriend in Dunfermline, Fife.
The pair met the 22-year-old at the Brasshouse nightclub after he had been on a failed first date.
Complaining of a headache, the male opted to head home early for his bed.
His partner chose to stay out, forming a quick friendship with Everard as the pair shared drinks.
They eventually jumped in a taxi together when the club ended, making the joint decision to head back to the home the woman shared with her boyfriend.
Arriving home they managed to awake the sleeping man, who then fell-out with his partner over the fact she had brought a stranger to their house.
He fell asleep on top of his bed fully clothed, and his girlfriend fell asleep on the sofa.
Everard then entered his room, lowering his trousers and underpants.
Believing it was his girlfriend, Dunfermline Sheriff Court heard the man then allowed him to continue touching his genitals and perform a sex act for a short while.
When he realised it was actually a male stranger, he leapt out of bed 'in a state of shock and anger', bursting into tears after Everard told him 'you liked it'.
The first time offender was jailed for 18 months on Monday after admitting assaulting the man while he was asleep, under the influence of alcohol and incapable of giving or withholding consent.
He has also been put on the sex offenders register.
Sentencing, Sheriff Craig McSherry told the court:
'This was a serious offence carried out with considerable forethought.His defence solicitor Stephen Morrison said he was 'ashamed' and appalled' by his actions – which happened when he was heavily intoxicated.
'You befriended the victim's girlfriend, went back to the flat with her, entered the bedroom and carried out the sexual assault.'
DailyMail UK