It's true! According to the Lord of the Rings 10-year anniversary special in the December edition of Empire magazine, McKellen calls Gandalf the "role of a lifetime" but says he nearly missed out on it.
The story goes that after he signed on to play Gandalf the Grey, his filming schedule nearly prevented him from doing so. And it was all doue to a little film called X-Men in which Sir Ian played Magneto.
It was thanks to a chance meeting at a London restaurant with New Line Cinema executive Bob Shaye that prevented McKellen from quitting. McKellen told Shaye about his scheduling conflict and Shaye told the actor that he would take care of it. The producer adjusted the schedule so they could proceed with filming Lord of the Rings for three months without McKellen, which allowed him to complete his role as Magneto.
Now I love McKellen and personally could not imagine anyone else playing Gandalf. However, I could totally see numerous actors playing Magneto. To think he almost couldn't play his "role of a lifetime" because he wanted to play Magneto.
Sometimes it is a really good thing to be in the right place at the right time...
Thanks, Mr. Shaye!!