Gay icon Sir Ian McKellen has revealed that his guest appearance on the upcoming series of BBC hit comedy Extras caused tension with creator Ricky Gervais.

The series features famous actors playing grotesque versions of themselves and has previously starred Kate Winslet, Ben Stiller and Samuel L Jackson.

Writing on his official website, McKellen revealed that he wanted rewrites to the script.

“There are many jokes in this episode of Extras , one of them being that Ian McKellen is gay and also that he is unsufferably pompous.

“That makes for tricky territory, particularly when the script has been written by two experts in irony, masters of the put-down, the snigger and the snub, Ricky Gervais and his partner (in, I’m pretty sure, the non-sexual sense) STEPHEN MERCHANT.”

The episode features an over-the-top turn by the Hollywood star. He insists on being referred to as Sir Ian at all times, something McKellen does not do in real life.

“I called Ricky Gervais to suggest the script had got me wrong, a little. I am one of those knights who prefers not to use the title professionally. Perhaps Ricky Gervais and Stephen Merchant had confused me with another acting ‘Sir’.”

McKellen was referring to fellow acting knight Sir Ben Kingsley, who raised eyebrows earlier this year by using is title to promote his film Lucky Number Slevin. Kingsley said the decision to bill him with his title was a mistake on the part of the film’s producers .

Fellow knight Johnathan Miller told The Seattle Times in February: “Ben Kingsley insists on being called ‘Sir Ben’, but that’s because he’s a little twerp.”

McKellen’s Extras appearance will be aired on BBC2 later this year.