Britain’s Prince Andrew — who allegedly earned his rhyming nickname, Randy Andy, for his ­energetic bedroom calisthenics — is in a royal pickle.

A friend of the late convicted ­pedophile Jeffrey Epstein, Prince ­Andrew has long been accused of taking sexual liberties with ­Virginia Roberts (now Giuffre), 35, the American woman who claims she once served as a “sex slave” of Epstein’s.

Starting at age 15, she alleges, she was forced to service Epstein’s rich and powerful pals, including ­Andrew. The prince has always ­denied the allegations, and Buckingham Palace has repeatedly called them “categorically ­untrue.”

Before Epstein was indicted on federal sex trafficking charges, which he escaped through his apparent suicide in a federal jail in Manhattan, he kept a list of contact information for people he knew or wanted to know.

Now, as US ­investigators ­attempt to piece ­together — and bring to justice — Epstein’s predatory network, they will be looking closely at his associates. Some of those people must be shaking — ­including, perhaps, Prince Andrew.

His handlers insist the prince never had sexual relations with that woman or any underage girl. In a show of support, the Queen and other members of the royal family attended church with him near Balmoral Castle last Sunday, the day after Epstein’s death.

Four years ago, things looked even bleaker.

In 2015, in a document filed by Giuffre’s lawyers in an American court, Andy was asked to testify after Giuffre laid out her allegations of princely abuse in a defamation suit against Epstein’s former girlfriend and alleged pimp, Ghislane Maxwell. In it, she claimed she participated in three alleged assignations with Andrew, including an orgy on Epstein’s private Caribbean island when she was 18, stocked with several girls she said appeared to be underage.

But the palace rejected the claims, and Andy never testified. Nor has he said a word publicly about the sexual allegations since giving one, pathetic statement in Davos that year.

“Firstly, I think I must, [and] want, for the record, to refer to the events that have taken place in the last few weeks, and I just wish to reiterate and to reaffirm the statements which have already been made on my behalf by Buckingham Palace,” the prince declared in perfect gibberish to a room filled with business leaders and reporters. “My focus is on my work, and this evening’s reception allows me to tell you about just a couple of the initiatives I have founded,” he said.

A journalist who evidently missed the memo warning mere mortals not to address the passionate prince directly, proceeded to step up and ask him to reiterate and reaffirm his verbal nonsense in plain English.

“Will you be making a statement under oath?” she asked. Andrew marched out of the room, stone-faced, without answering.

He never explained his relationship to Epstein. He never revealed the kind of important “work’” about which he is so passionate.

And he never said what the heck he was doing posing for a photograph, a middle-age man with his hands on a then-17-year-old girl’s bare midriff.

The palace, incidentally, rejected Giuffre’s mailed request to have him testify. He may have to speak up now.

Tales of Andrew’s alleged sexual villainy resurfaced again Friday, mere hours before Epstein’s death, with the release of some 2,000 pages of documents from the defamation suit Giuffre brought against Maxwell, who has not been charged with a crime. (The case was settled out of court for an undisclosed sum.)

Included were detailed allegations, never before made public, of the young woman’s alleged princely trysts, plus deposition testimony by another young woman who alleged that Andrew groped her breast while sitting on a couch in Epstein’s New York City townhouse, in 2001 when she was 21.

Suddenly, Andrew’s elite immunity appears to be vanishing in the post-#MeToo era. Several British lawmakers are demanding that the royal be investigated for his ties to Epstein. On this side of the Atlantic, a ­furious Attorney General William Barr said, without naming names, “Any co-conspirators [of ­Epstein’s] should not rest easy.”

He might be targeting Maxwell. But Randy Andy shouldn’t rest easily. All the blue blood coursing through his veins might not protect him.