A SEX attacker pulled down the pants of a serial rapist and laughed at the size of his manhood, a court was told.

Ian Dempster, from Elphinstone, was said to have taken down the shorts of Jonathan Mallon to ridicule him while the pair were serving time at HMP Edinburgh last year.

Dempster was also accused of striking Mallon between his legs with a pool cue as he played the game with a fellow prisoner at the Capital prison’s sex offender wing Ingliston Hall – home to some of Scotland’s worst child abusers.

The court was told that Dempster claimed he only chased the man with the cue after Mallon had come up behind him as he played pool on one of the wing’s two tables and simulated sex.

The bizarre tale was heard when Dempster had appeared in the dock for a part-heard trial at Edinburgh Sheriff Court last month accused of assaulting and sexually assaulting Mallon at the prison in December 2015 and January 2016.

But when the trial resumed on Monday, Sheriff Michael O’Grady was told that 61-year-old Dempster was now pleading guilty to assaulting Mallon by pulling down his clothing and exposing his genitals at HMP Edinburgh on January 2 last year.

Dempster’s not guilty pleas to sexually assaulting Mallon by touching his testicles and assaulting the rapist with a pool cue, between December 1 and 31, 2015, were accepted by the Crown.

Dempster was jailed for three years in 2011 for committing five sexual assaults. He was ordered to be supervised for a further three but broke his release order in 2015 by travelling to England without permission and is currently back in jail.

While Mallon, from Greenock, was ordered to spend at least 10 years in jail after being found guilty of a 13-year campaign of terror that involved him raping five woman and sexually assaulting a sixth.

During last month’s trial, the Capital’s sheriff court saw a series of the country’s most notorious sex offenders – including baby rapist Jonathan Forshaw and 67-year-old child abuser Hugh Mitchell – give evidence in the trial.

Mitchell said he saw Mallon looking “shocked” after turning round to see him pulling his shorts back up but said he did not witness what had happened.

Forshaw and fellow offenders Arthur Renwick, 60, Faraz Ali, 29, and 46-year-old Archibald Palmer all told the court they had seen nothing happen between Dempster and Mallon during the alleged incidents in December 2015 and January last year.

Mallon, 37, gave evidence that he felt “sick, angry and upset” after claiming Dempster had touched his genitals during the pool game, then humiliated him by exposing him to two other prisoners as he stood chatting in their cell.

Mallon told prosecutor Mark Keane: “I was leaning over the table to take a shot and he [Dempster] put his cue between my legs and hit my balls.

“I said that is ****ing sore, but he just laughed.

“Later I was coming out of my cell and Dempster came over and grabbed my privates with his hand. He smacked them with his hand and just laughed.

“I was angry because I thought he was picking on me as I am a gay man.”

Mallon said the incident when he had his privates exposed as he chatted to Renwick and Mitchell in their cell happened later the same evening.

He said: “I was telling Arthur [Renwick] about what had happened [earlier] and that I was annoyed. A split second later I found my trousers and pants were pulled down and he [Dempster] said: ‘What a wee willy.’

“I didn’t know he was behind me at the time but I said he was being reported. I was wearing shorts and underwear and he pulled them right down and my private parts were exposed.

“I felt sick, I felt angry and I was upset.

“They might have been laughing as I’m quite small down there.”

But during cross examination, Dempster’s solicitor Graeme Clark asked Mallon: “Around this time were you behaving in a sexually provocative way towards Mr Dempster? Were you trying to wind him up by blowing him kisses? Did you expose [yourself] to him?

“Mr Dempster denies hitting you with the pool cue, but on one occasion when he was playing pool he says you came up behind him, grabbed him by the hips and pretended you were having anal sex with him. He then chased you with the pool cue.”

Mallon denied all the brief’s claims.

On Monday, solicitor Mr Clark said that the incident Dempster had pleaded guilty to had been “effectively a prank”.

The solicitor added his client had been serving a sentence at the time after being recalled in 2015.

Mr Clark said: “Obviously these allegations are quite old and he has pled guilty to a much lesser charge.”

Sheriff Michael O’Grady QC decided to admonish Dempster on the assault charge after hearing he had spent two months on remand due to the allegations.

Dempster was cleared of assaulting Jonathan Mallon by striking him with a pool cue and sexually assaulting him by touching his privates at HMP Edinburgh between December 1 and 31, 2015.

He admitted to assaulting Mallon by pulling down his clothing and exposing his privates on January 2 last year.