A man rejected by his ex-wife went on to have sex with her bull mastiff dog, a court has heard.
Kelly Thacker claims to have found her ex-husband Nicholas Saunders, with whom she has two children, in her bed having intercourse with Sacha the dog, on 15 January 2011.
The 46-year-old denies the charge but accepts he was naked in the bed with the dog.
Gloucester Crown Court heard Saunders had been kicked out of his house following an argument with his girlfriend and had sought out sympathy at his ex-wife's home.
The pair had remained on friendly terms following their separation and Saunders had visited Mrs Thacker and stayed overnight at her house in the past.
However, according to the prosecution, when Mrs Thacker made it clear to him he did not have a chance with her he turned to the large dog.
Frank Abbott told the jury of seven women and five men that Saunders had got undressed and climbed into Mrs Thacker's bed while she went downstairs to sleep.
"A little later, the dogs - one of which is a bull mastiff, a large dog - came upstairs and laid on the bed," Mr Abbott said.
"He (Saunders) said to the dog 'You've just ruined my chances'.
"Meanwhile, downstairs in the lounge, Mrs Thacker could hear things going on upstairs.
"She heard the defendant rummaging around.
"She then heard him whistle to the dogs, which had since gone downstairs, and they went upstairs.
"Sasha, the dog, got onto the bed. Mrs Thacker became curious and she went upstairs.
"She saw him, in fact naked, the dog on the far side of the bed facing away from the defendant and that he was clearly trying to put his penis into the dog's vagina.
"She couldn't believe what she was seeing."
The jury were told Saunders claims he was in the bed with the dog, but denies trying to have sex with it.
Following his arrest Saunders provided police with a sample from his penis and forensic examinations showed the DNA of a dog was found, Mr Abbott told the court.
"There is no doubt that that is the position and that supports what the witness said happened," Mr Abbott added.
He told the jury they would have to consider the possibility the dog left DNA on the bed and because Saunders was naked it could have been picked up from the covers.
But he also asked them to think about where the DNA had been found on Saunders' penis.
Saunders, of Bell Lane, Lechlade, Gloucestershire, has pleaded not guilty to having intercourse with an animal.
Giving evidence, Ms Thacker, who was married to Saunders from 1999 to 2002, told the court the incident left her in "utter shock".
Ms Thacker, who owns a male boxer as well as the bull mastiff dog, said her ex-husband turned up at her house at about 1.45am and was "a little bit drunk" following the argument with his girlfriend.
She said: "He was staggering a bit. He said 'She's f***** me about again'. I presumed that she'd been seeing someone else."
She told the court that later that night she went upstairs and was looking through the banisters when she saw Saunders with the dog.
"It was just too quiet, whereas he'd been mumbling before, so I thought I would just go and check," she said.
"I didn't go all the way up, just halfway to the top banister.
"The bull mastiff was leant on her side and he (Saunders) was trying to guide his penis into her.
"I think I must have hit some kind of shock and I hid back a bit. I then looked round again.
"He was on all fours holding her thighs. He was having intercourse with her. She wasn't even moving.
"I plucked up the courage to go upstairs and told him to get out. He jumped off the dog and laid down and just said he was tired."
Asked how she had been affected by what happened, Ms Thacker replied: "It was just utter shock, you don't think anything like this could happen."
Ms Thacker reported the incident to the police later that day after discussing the incident with their teenage daughters.
But in cross-examination it was suggested to the court that it was Saunders who spurred Ms Thacker's advances that night.
"Isn't it right that as Mr Saunders climbed over the dog to get into bed that you said 'I bet you'd rather shag the dog than me'," Sarah Jenkins, defending, asked.
"No," Ms Thacker said.
Miss Jenkins went on: "You were spurred by him that night. It was out of spite you made this complaint."
It was also alleged that Ms Thacker was annoyed that her ex-husband used her house as a bed for the night and it was for these reasons that she made the allegation against her ex.
Mrs Thacker told the court: "I don't lie. It's been a long, hard year and a half, but I stick to what I saw."
A specialist forensic scientist told the court that a swab taken from Saunders' penis showed a 100% match with a domestic dog.
But Victoria Moore, who has worked with animal DNA for eight years, said it was not possible to tell the type of dog, its sex or the source of the DNA.
Ms Moore told the court that it could have come from a number of sources, including blood, salvia or hair.
The trial continues.
Comments have been disabled for legal reasons.