Michael Gambon has withdrawn from Alan Bennett's eagerly anticipated new play at the National Theatre, just weeks before opening night.

Gambon, 68, was set to take the lead in The Habit of Art, but has been forced to pull out due to ill health. While acknowledging that the timing is "unfortunate", he played down the severity of his condition, saying merely that he had been told by doctors to rest for a "couple of weeks". "I'm temporarily not firing on all cylinders," he said. "This means I must let the show go on without me."

Bennett's first play since the runaway international success of The History Boys, The Habit of Art imagines a meeting between the poet WH Auden and composer Benjamin Britten, who collaborated early in their careers but later fell out. Characteristically for Bennett, it is also a teasing piece of metafiction – set among a company of actors in a rehearsal room.

Gambon will be replaced in the role of Fitz – the actor who plays Auden – by Richard Griffiths, a longtime Bennett collaborator. Griffiths, who was last seen on the London stage in 2007's Equus, also took a central part in The History Boys, playing the inspirational (if lecherous) teacher, Hector.

The Habit of Art's director, Nicholas Hytner, said that he was extremely sorry Gambon would be unable to continue with the production and "couldn't be more grateful" to Griffiths for agreeing to take on the challenge at short notice. The new cast member doesn't have long to learn his lines: the first preview will go ahead as planned on 5 November. The press night (17 November) also remains unchanged.

"The Habit of Art is about the business of putting a play together as much as it is about making music or poetry," Hytner continued. "We're looking forward to taking creative advantage of this unexpected twist in our own rehearsal process."