Spurned Stuart Totten, 42, bombarded his ex partner with hundreds of phone calls and text messages for almost a year.
He would also send explicit photos of himself to the man, who cannot be named for legal reasons.
In one incident he sent over 160 text messages to the man in just over 90 minutes.
Totten even used gay internet forums to post abusive messages about his former partner online and revealed details about their sex life.
He also turned up at the man’s flat and demanded entry, even breaking open the front door before being told to leave after his former partner phoned the police.
And when he was bailed from court with strict instructions not to contact his former partner, who he had a relationship with for 18 months, he continued to telephone him in a desperate bid to strike up conversation.
Totten, of Uddingston, Lanarkshire, has now appeared at Hamilton Sheriff Court and admitted causing fear and alarm during his stalking campaign between August 2013 and July 2014.
Depute fiscal Imran Bashir told the court how the pair had an on off relationship before it eventually finished for good.
He said: “Both the complainer and the accused were in a relationship for a period of time and it was on and off.
“There were periods where it had ended and they then got back together.
“Some of the offending was when the relationship was still on and off.
“There were an increasing number of incidents involving the complainer and the accused’s behaviour towards him.
“The complainer wanted no more contact with him but the accused made a number of efforts to contact him directly or indirectly.
“Some of the accused’s behaviour was also on internet forums where the complainer was also a participant.
“One night he received an email from the accused which showed him in a sexually explicit position while undressed.
“The complainer was upset by this and told the accused he was going to give a copy of it to the police because he didn’t want to receive anything of this nature.”
Totten also turned up at his ex-partner’s home and launched a tirade of abuse at him.
Mr Bashir added: “Another evening the complainer was in his home address when he heard the noise of the front door and when he looked through the spy hole he observed the accused outside.
“He was fearful of the accused and hoped he would leave however the accused began banging the door and was shouting aggressively ‘I know that you are in there, get the f****** door open now’.
“The complainer was extremely alarmed and fearful due to the aggressive nature and returned to the door to make sure it was locked.
“It appeared it was not locked securely so he put the chain across and the accused placed his foot in the door causing the chain to break.
“The accused began to shout aggressively to the complainer saying ‘you are f******* scum, you are going to pay for what you have done to me.’
“The complainer managed to get the door closed and locked but the accused opened the letter box and continued to shout and swear.
“Police were then contacted.”
Sheriff Thomas Millar deferred sentence until next month for reports.
Totten refused to comment.