Funny man Ricky Gervais has landed a guest-starring role on ABC’s midseason musical comedy Galavant, EW has learned exclusively.

The series stars Joshua Sasse as the titular hero, who sets out on a quest for revenge against the king for stealing his true love—all set to music. Gervais will play a medieval wizard named Xanax, who is well-known for having the best potions in all the land and excels at guiding his clients through alchemy-induced trips down memory lane.

Gervais (Extras, Derek, The Office) joins previously announced guest-stars John Stamos and Hugh Bonneville.

Galavant is slated to premiere in early 2015 on ABC.