A heartfelt video message from Doctor Who star Peter Capaldi to a bereaved autistic boy has gone viral on YouTube.

9-year-old Thomas Goodall, who lost his grandmother in October, received the video message from Capaldi after writing to the show.

In the video, in which Capaldi stays in character as the Doctor, he tells Thomas, "Thank you very much for your letter. I really enjoyed getting it".

He adds, "When Clara and I are travelling around in time and space, sometimes bad things happen to us.

"And you know what, Thomas? Sometimes sad things happen to us too. So it's nice to know that there's somebody like you out there who's on our side. And you should know that we're on your side too.

"So you look after yourself, and take care, and be happy."

Ross Goodall, the father of Thomas, said he was surprised and thankful for the message Capaldi sent.

"[He] Made such a huge difference and helped him cope with the hardest of days. It was an incredibly kind thing to do that has help Thomas gain perspective and not feel so alone in his grief. Where Thomas is autistic, he doesn't feel emotions the same way the rest of us do so this has been incredibly hard for him. This message seems to have given him the strength to keep going, with his chin up," he posted in a YouTube message.

"[I] Wish I could thank Mr Capaldi in person," he added.

The eighth series of Doctor Who ended on Saturday in a gripping finale in which the Doctor battled his old enemies the Cybermen and the Master. Capaldi will next be seen as the Doctor in the Christmas special to be aired on 25 December.