Simon Bowes-Lyon, Queen Elizabeth II’s first cousin twice removed, has pleaded guilty to sexually assaulting a woman at his ancestral home of Glamis Castle in Scotland.

The 34-year-old, who is the current Earl of Strathmore and Kinghorne, pleaded guilty on Tuesday to violently attacking the 26-year-old last February, the BBC reported.

Bowes-Lyon was granted bail during a hearing at Dundee Sheriff Court and his sentence was deferred. He was also placed on the sex offenders’ register. He could face up to five years in prison.

Bowes-Lyon was hosting an event at the 16,500-acre estate at the time of the attack, the U.K.’s Daily Record reported. According to the outlet, he forced his way into the sleeping woman’s room, tried to pull off her nightgown, groped her and then assaulted her for more than 20 minutes. 

QUEEN ELIZABETH IS PLANNING HER ROYAL RETURN, EXPERT SAYS: ‘WE ARE ALL HOPING THIS YEAR WILL BE DIFFERENT'

"She was asleep and was woken by knocking at the door," said fiscal depute Lynne Mannion.

Mannion said Bowes-Lyon pleaded with the woman, "It’s important. Please let me in."

"She got up," Mannion continued. "The second she opened the door he pushed his way in and pushed her onto the bed. He was very drunk and smelled of cigarettes. He told her he wanted to have an affair." 

The court heard Bowes-Lyon then began to sexually assault the woman who resisted and attempted to raise her voice so another guest would hear her. However, he repeatedly pushed her onto the bed and continued the assault, threatening "I’m going to f--- you."

PRINCESS DIANA’S EX HASNAT KHAN SLAMS BBC’S MARTIN BASHIR FOR ‘EXPLOITIVE’ 1995 TV INTERVIEW

Glamis Castle, Angus, Scotland (Getty Images)

The court also heard that Bowes-Lyon called the victim "a rude, mean, bad and horrible person" who could not tell him what to do in his own home.

The woman eventually managed to get Bowes-Lyon out of the room and then began reaching out to her colleagues and boyfriend for help. Bowes-Lyon returned and tried to get in the room again, but this time a guest from another part of the castle came in to help.

According to the outlet, the guest said the woman was "distressed" when he spoke to her. When he attempted to confront the aristocrat about the incident, he had already fallen asleep. The woman fled the castle in the morning and reported the assault to police.

At the time, Bowes-Lyon was hosting several people over the weekend for a lifestyle magazine feature, Newsweek reported. According to the outlet, the event included gin tastings, helicopter rides, shooting and a tour of the castle. The attack came on the second night after a black-tie dinner.

CLICK HERE TO GET THE FOX NEWS APP

Simon Bowes-Lyon is Britain's Queen Elizabeth II’s (pictured) first cousin twice removed. (Ben Stansall - WPA Pool/Getty Images)

The outlet reported that outside of court, Bowes-Lyon said he was "greatly ashamed" of his actions.

"Clearly I had drunk to excess on the night of the incident," said the earl, as quoted by the BBC. "I should have known better. I recognize, in any event, that alcohol is no excuse for my behavior. I did not think I was capable of behaving the way I did but have had to face up to it and take responsibility. My apologies go, above all, to the woman concerned, but I would also like to apologize to family, friends and colleagues for the distress I have caused them."

Glamis Castle, the seat of the Bowes-Lyon family since 1372, was the childhood home of the Queen Mother, People magazine reported. Bowes-Lyon is also the great-great nephew of the Queen Mother, who passed away in 2002 at age 101.