The controversial singer apparently discovered that the Gandalf actor is a "huge fan" of his when they met at the Attitude Awards on Tuesday (October 16).
"Rylan went to the awards and was half expecting to just get more abuse," a source told The Sun. "Everywhere he goes people give him stick but this was the complete opposite.
"Sir Ian McKellen of all people came up to him and said he was a huge fan and hoped he did well on the show.
"They swapped numbers and Rylan couldn't believe his luck when Sir Ian said he'd be happy to offer him some advice."
Photo gallery - The 2012 Attitude Awards:
Copyright: Rex Features Ray TangClark drew further criticism this week when he and fellow X Factor contestant Lucy Spraggan were ejected from their London hotel after a drunken night out.
The ex-boyband member recently admitted that he is aware of his "joke act" status and has "no expectations" of winning The X Factor.
Digital Spy breakfast show - watch Catriona Wightman discuss the day's biggest stories including Adele, Emmerdale and Kylie Minogue: