Speaking in an interview on BBC’s Radio 2, the Scottish star said he felt it was “time to move on to different challenges” after being in the role since 2013. The actor will leave the Tardis for the last time in the 2017 Christmas special.

In the surprise announcement he said: “I’m always someone that did different things. I’ve never done one job for three years before and I feel it’s time for me to move on to different challenges.”

He added: “One of the greatest privileges of being Doctor Who is to see the world at its best,” he said. “From our brilliant crew and creative team working for the best broadcaster on the planet, to the viewers and fans whose endless creativity and generosity and inclusiveness points to a brighter future ahead. I can’t thank everyone enough. It’s been cosmic.”

Departing show runner Steven Moffat also said in a statement: “For years before I ever imagined being involved in Doctor Who, or had ever met the man, I wanted to work with Peter Capaldi. I could not have imagined that one day we’d be standing on the Tardis together. Like Peter, I’m facing up to leaving the best job I’ll ever have, but knowing I do so in the company of the best, and kindest and cleverest of men, makes the saddest of endings a little sweeter.”

Moffat will be replaced by Broadchurch creator Chris Chibnall.

Capaldi became the 12th actor to play Doctor Who in the BBC sci-fi series when he took over the role from Matt Smith in 2013. He’s the fourth Doctor since the Beeb relaunched the series in 2005 (Christopher Ecclestone and David Tennant also both had stints as the Doctor).