Sir Ian McKellen has revealed new details about how X-Men scheduling almost forced him to back out of playing Gandalf in Lord of the Rings.

We’ve got an unlikely hero to thank for Sir Ian McKellen appearing as Gandalf in The Lord of the Rings and The Hobbit: Bryan Singer, the director of X-Men.

In a fantastic roundtable interview posted on IGN, McKellen reflects on his iconic role, and of course discusses how he almost didn’t return for The Hobbit trilogy. (As he terrifyingly states, “At my age, each job might be your last.”)

But what The Hobbit fans might not realise is that McKellen was very close to not playing Gandalf at all. Back when they were casting for Lord of the Rings, the actor was allegedly offered the role only after Sean Connery turned it down.

McKellen accepted the role, but, “Before Peter Jackson asked me to play Gandalf, Bryan Singer asked me to play Magneto,” he says. “That came first.”

McKellen was only able to say yes to Gandalf in the first place because his schedule allowed it. But then the X-Men filming dates changed.

“I had to call Peter up and say, ‘I’m sorry, I can’t play Gandalf because my initial commitment has changed its dates,'” McKellen recalls. And that, of course, is usually the end of the line for actors who have to back out of projects.

This story has been told before: of how, miraculously, the schedules were re-arranged, allowing McKellen to appear in both projects. But in this new interview, McKellen gives all the credit to the X-Men director.

Singer heard the news, called up McKellen, and said, “YOU SHALL NOT PASS on playing Gandalf!” (Okay, no, but let’s just pretend that’s how it happened.)

“It’s only because Bryan Singer is a gentleman and talked to Peter Jackson and they agreed quite unofficially, nothing in writing, that Singer would get me out of X-Men in time to do Fellowship of the Ring that I was able to do both parts,” the actor reflects. “It’s just a fluke and it tickles me, really.”

In the interview, McKellen also indicates that filming the original Lord of the Rings trilogy was a lot more emotional than The Hobbit (where he famously had to spend an uncomfortable amount of time acting alone in front of a green screen).

For the Lord of the Rings filming wrap-up, they had a big ceremony. “For The Hobbit, I suspect it will just be b’bye. ‘Bye-bye, Hobbit, bye-bye.’ I don’t know,” he says. We hope they managed to make it memorable.

The Hobbit: The Battle of the Five Armies hits cinemas on December 17.