The show will be the final in Lloyd's second Trafalgar Transformed season, and opens on 27 January 2015 (previews from 16 January).
McAvoy, who last year played Macbeth for Lloyd as part of the director's inaugural tenancy at the Studios, will play the fictional 14th Earl of Gurney, a nobleman who inherits his father's estate, and thinks he's Jesus.
The production marks the first revival of Peter Barnes' satirical comedy since its first run in the 1960s, when it won the Evening Standard's best drama award.
Further casting includes Michael Cronin (Bishop Bertie Lampton), Serena Evans (Lady Claire Gurney), Paul Leonard (Ralph Gurney), Elliot Levey (Dr Herder), Forbes Masson (McKyle) and Rosy Benjamin, Andrew Bloomer and Oliver Lavery.
The production, which follows East is East at the venue, runs until 11 April 2015. Design is by Soutra Gilmour, with lighting by Jon Clark, sound by Ben and Max Ringham, choreography by Darren Carnall and musical direction by Huw Evans.