Ricky Gervais is the greatest actor in the world. He says so Himself on His website. It's not always easy to know quite when RG means what he says, so it was with enormous trepidation that I joined him at Pinewood Studios for two days filming an episode of the second series of Extras, the hit show for BBC TV and HBO. It wasn't made any easier that the character I was playing was called "Ian McKellen". In Extras RG plays another actor Andy Millman, star of a dodgy BBC sitcom When the Whistle Blows, who is eager for a change and comes to audition for a part in a new stage play which Ian McKellen is to direct. With me so far?

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, RG and his partner (in, I'm pretty sure, the non-sexual sense) Stephen Merchant, now graduated from co-writing The Office to be an actor as Andy Millman's agent.

I don't want to spoil the fun but this is how my first scene began:

INT.CASTING ROOM.DAY

An ASSISTANT is walking ANDY in. Assorted theatre-types are sat around talking. The ASSISTANT and ANDY approach SIR IAN MCKELLEN.

As I'd been invited to comment on the script to suit my personality, I called RG 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 RG and SM had confused me with another acting "Sir". I suggested a substitute joke more in keeping with my attitude to such formalities:

ASSISTANTExcuse me. This is Andy Millman

IAN McKELLENOf course it is. Welcome Andy.

They shake hands

ANDYIt's an honour to meet you Sir Ian.

IAN McKELLENOh no, please, it's not Sir Ian.

ANDYSorry, Mr McKellen.

IAN McKELLENNo, not him either. No titles please. Please don't separate me out from the rest of you. Please. We are all workers at the coal-face. If you're going to call me Sir Ian then I'm going to have to call you Mr. Milkman and that would never do would it?

On his mobile, RG was non-committal. You can judge the compromise we made when the episode is aired later this year.

It was a thrill to be so close to a comic actor in his prime but nerve-making too. So I was relieved somewhat when after one of my lines (which he had co-penned) RG guffawed so loudly that we had to start the scene again — and then again, as he laughed some more. This was reassuring and alarming simultaneously. I mean, if he ever stopped laughing would it mean I was no longer being funny? I said I wished he could control the open expression of his glee as I wasn't sure I could be much good if he kept interrupting. "But that's it you see," RG confided straight-faced, "My job is make you look crap so I can win the BAFTA". Then the greatest actor in the world roared with laughter. So did I. One of us, at least, was acting. — Ian McKellen, August 2006