Hugh, known to viewers for his role as the Earl of Grantham, will swap his country pile for a garden shed in the family comedy which begins filming next month.

David will also make an appearance playing the Prime Minister after notably playing a fawning aide to the PM in his hit comedy Little Britain.

In the story, lonely 12-year-old Chloe befriends local tramp Mr Stink and invites him to hide out at the end of her family's garden. The book by David, who has worked with Men Behaving Badly writer Simon Nye to adapt the tale, has sold more than a quarter of a million copies.

Hugh said: "I'm delighted to be adding my own whiff to the odour that emanates from David Walliams, and his very funny, touching and thought-provoking story."

David, whose production company is working on the hour-long drama, said: "I am thrilled that Hugh is playing Mr Stink. He is one of the most popular and talented actors around, and is the perfect person to bring out the character's humour and sadness."

Executive producer Mark Freeland, the BBC's head of in-house comedy, said: "I fell in love with David's book when I read it to my kids. I fell in love with David 15 years ago."