Capaldi - best known for his expletive-fuelled rants as spin doctor Malcolm Tucker in the political sitcom - will play Cardinal Richelieu in the 10-part series.
The BBC1 series, to be called The Musketeers, will star Luke Pasqualino - who has appeared in Skins and The Borgias - as D'Artagnan.
Capaldi, recently seen in BBC2 drama series The Hour, will play "a shadowy character who will stop at nothing to achieve his objectives", according to the BBC.
The rest of the crack team of Musketeers will be played by Tom Burke (Athos), Santiago Cabrera (Aramis) and Howard Charles (Porthos).
The Alexandre Dumas book has been brought to life a number of times including major movies in 2011 and 1993, as well as a US animation series screened regularly during children's TV show The Banana Splits.
The new version is being made by the BBC, together with its commercial operations BBC Worldwide and BBC America.
Creator and executive producer of the new series, Adrian Hodges, said: "I'm thrilled to be working with such a dynamic, talented and attractive ensemble cast on our new version of The Musketeers.
"This series is all about passion, romance, heroism and action, and I can't think of a better group of actors to embody those diverse qualities."
Filming begins next month and the series - set in 17th-century Paris where the Musketeers are King Louis XIII's personal bodyguards - is to be screened next year.
Other stars in the series include Maimie McCoy, recently seen in Loving Miss Hatto, Tamla Kari from The Inbetweeners Movie and Hugo Speer, whose roles have included The Full Monty and Bedlam.
Ben Stephenson, the controller of BBC drama, said: "The ambition of this drama is clearly illustrated with such a world-class mix of talent - the perfect team to take the audience on thrilling action adventures every week."