Sir Ian McKellen has sent a powerful message to people afraid of revealing their sexuality while discussing actress Ellen Page’s recent announcement that she is a lesbian.

The X-Men actor, who is openly gay, offered words of advice to those worried about coming out of the closet during a BuzzFeed Brews interview.

“Anyone in public life who comes out, comes out primarily for themselves, and their life is immediately improved," he said.

Download the new Independent Premium app Sharing the full story, not just the headlines

"That’s what happened to me. The world [became] a slightly better place.”

The Lord of the Rings actor said he believed his role in the trilogy and the fact that he is openly gay would become his lasting legacy. “I often thought my gravestone would say, ‘Here lies Gandalf. He came out.' Those are two of the proudest achievements that I’ve got.”

Sir Ian, a vocal spokesman for LBGT rights, recently addressed an open letter to Russian President Vladimir Putin signed by 27 Nobel laureates criticising the ban on “homosexual propaganda”.

He said Page’s declaration of her sexuality had pushed the gay rights movement towards “a happy conclusion”. “That gladdened my heart so much."

“For people who are lonely … reading that about someone whose career they follow is a little bit of a help and encouragement to them to think it does get better.”

He was joined by Sir Patrick Stewart during the interview, who found himself mistakenly outed as gay earlier this week by the Guardian columnist Jane Czyzselska when she cited him as an example of a gay actor who cheered Page on for her public disclosure.

His humorous reaction to being 'outed' was captured in a tweet, when he wrote: "But I have, like, five or even SEVEN hetero friends and we totally drink beer and eat lots of chicken wings!"