David Walliams has told how he was hit so badly by depression while on the verge of stardom that he was admitted to a psychiatric hospital.

The comedian feared he was going mad when he checked into The Priory — just weeks before filming began for Little Britain, the show that would propel him into the mainstream.

His struggles are a far cry from his upbeat image as one of UK’s favourite entertainers.

In his new book, called Camp David, Walliams says his black moods became an issue at university but reached a new low while filming BBC comedy Cruise Of The Gods in November 2002, after a relationship ended.

A diary entry from the Britain’s Got Talent judge, 41, reads: “Today the stone in my heart turned into a rock.

“News reached me that my ex-girlfriend had a new boyfriend. The tears started. I went outside. Suddenly the crying was uncontrollable. I stood out in the car park, bent double with grief. I crawled back to my dressing room and lay on the floor, sobbing.

“I had never experienced this level of pain or emotion before. It was terrifying.

“I was shaking. It was like I was having a nervous breakdown or going mad or both.”

The star, who has earned a fortune from his career and is married to model Lara Stone, says he spent “night after night with no sleep”, while the days were “like a walking death”.

In his autobiography, Walliams writes: “Many people who suffer from depression confirm early morning is the worst time. There is no one to call. Your friends or family tell you, ‘Call me at any time’. But at 4am you don’t feel you can.

“It’s dark outside — there isn’t even the sound of the birds to keep you company. So I would lie there until the curtain edges grew light and the room took shape. It was not just the terrible elemental sadness I felt, but fear. Fear of death, fear of life, fear of love, fear of everything.” A matter of weeks before Little Britain’s first series went into production, he told comedy partner Matt Lucas that his psychiatrist had suggested he go to The Priory in south-west London. He kept it a secret from his parents as he did not want them to worry.

The comedian writes that he left The Priory after a week with “a paper bag full of anti-depressants and sleeping pills”, and went to stay with his “knight in shining armour”, fellow comedian Rob Brydon.