It was discovered during a search of her handbag when she arrived for a night shift two years ago.

Sharples, a support officer at HMP Garth, in Leyland Lancs, claimed she had used the syringe to administer medicine to her granddaughter. But tests revealed the residue matched the DNA of prisoner Marvin Berkeley — or his identical twin brother, the jury heard.

A love letter from the inmate was later discovered in Sharples’ underwear drawer during a police search of her home.

Ms Camille Morland, prosecuting, said: “They had a relationship that was close, covert and sexually intimate, if not necessarily physically so, because of the fact he was in prison.

“The letter and its contents are evidence of the relationship between the prisoner and the defendant which went beyond that permitted by her role.”

“I can’t talk to you properly on them walkways but whoever has reported you for talking to me has took the p*** and is totally out of order. I know it’s not no other con so beware of the people you’re working with. Look close to home Alison.

“To be honest, you’re the only real and down to earth one in here.”

Sharples’ pal Nicola Ball told police that she was besotted with Berkeley, who was serving time for a serious offence.

The court heard that she said Sharples had gathered the semen from a sample pushed under a cell door in a carrier bag.

Ms Ball said Sharples was open with her about the relationship and even told her she had taken a phone into jail for her lover.

Sharples, of Chorley, Lancs, denies misconduct in a public office by having an intimate relationship with the lag. The case continues.