Afterlife star Ricky Gervais has defended comedian James Corden after he was accused of 'joke theft' copying his gag word for word.

The Gavin and Stacey actor was discussing Elon Musk's recent Twitter takeover on his show Corden's Late Late show.

Corden says: "When you see Elon Musk talk about Twitter, he does this thing where he goes, 'Well, it's the town square.' But it isn't, 'cause if someone puts up a poster in a town square that says, ‘Guitar lessons available,’ you don’t get people in the town going, ‘I don’t wanna play the guitar! I wanna play the piano, you piece of s***!"

READ MORE: The Oarsman, Marlow launches new Sunday Roast specials menu

His audience broke out in laughter but Gervais fans on Twitter quickly recognised the joke had been made before.

Gervais said he felt sorry for Cordon on Twitter, assumuing one of his writers must have written the joke for him as it was copied word for word.

Cordon then tweeted: “Inadvertently told a brilliant Ricky Gervais joke on the show last night, obviously not knowing it came from him.

ALSO READ: Bucks girl to represent UK Eurovision Junior song contest

“It’s brilliant, because it’s a Ricky Gervais joke. You can watch all Ricky’s excellent specials on Netflix.”

Do you think it is joke theft?