Miley Cyrus wanted to star in Black Mirror as a pop star to “piss people off”, show creator Charlie Brooker has said.

The fifth series of the science fiction anthology programme includes three episodes, one of which stars Cyrus in a story that Brooker and his co-producer Annabel Jones said she identified with on a number of levels.

The Wrecking Ball singer plays a pop star whose real life dramatically appears to differ from the one that is portrayed to the public in the episode called Rachel, Jack and Ashley Too.

The trailer for it shows Cyrus unveiling a robot-type device through which she can speak to her fans, before things take a sinister turn in classic Black Mirror fashion.

Speaking at a Q&A for the episode, Brooker and Jones said that Cyrus was keen on being part of the episode from the start.

Jones said: “She read the script and, as you can imagine, there were quite a few things in the script she identified with, and she’s got a very sarcastic sense of humour.

“She’s very acerbic, she’s very funny and she delights in subverting things; her whole career has been about the Disney pop star who tries to carve out her own identity and, as a result, has faced a lot of opposition from her label and her fans in some respect, so she’s been on that journey.

“She found it hilarious. She was like, ‘oh my God I’m going to have so much fun with this.'”

Brooker added: “I seem to remember she said, ‘oh, it’ll piss people off and pissing people off is kind of my thing.'”

Jones said that she “still can’t believe” that Cyrus signed up to take part in the episode, which was written by Brooker before they knew who they would cast.

He said: “After the script was written we were just discussing who could play the part of an international pop star and we sort of thought, well in a dream world it would be somebody like Miley Cyrus.”

Brooker said that they thought “that was f****** stupid talk”, but that they “had nothing to lose” by sending the script to her.

“We thought we’d just be ignored, to be honest,” he added.

Charlie Brooker and Annabel Jones
Charlie Brooker and Annabel Jones (Matt Crossick/PA)

“And but we got the script to her and it turned out she’d seen the show and liked it and read the script and liked it and before you knew it, we were having a Skype chat, and then she said she’d do it.”

Jones said that Cyrus had a lot of input with the script, and “talked a lot about her own experiences”.

She said a lot of the details of Cyrus’ life have been engineered into the script.

Jones added: “She had lots of thoughts on the music and the performance of the music and the look, and the relationship between the idol and the fan, which is a very interesting and powerful relationship in today’s world.”

The other two episodes in the star-studded new series of Black Mirror includes the likes of Andrew Scott, Anthony Mackie and Topher Grace.

The dystopian yet often darkly comic series, which takes a scathing look at modern society and alternative realities often relating to the overuse of technology, was created by Brooker and debuted in 2011 on Channel 4.

The programme moved to streaming giant Netflix in 2016.

Black Mirror season five premieres on Netflix on June 5.