Dumas' The Three Musketeers is loosely based on Gatien de Courtilz de Sandras' Memoirs de M. d'Artagnan. In turn, the Memoirs are based on the life of the real-life d'Artagnan, whose real name was Charles de Batz-Castlemore.
Charles came from lesser, newer, Gascon (see Gascony) nobility. His merchant great-grandfather had bought their noble status (and the estate of Castlemore, including its chateau) no later than the mid-16th century. Charles' father, Bertrand, married into the well-known Montesquiou d'Artagnan family, which is where the name comes from. Charles was the second or third eldest boy out of four boys and three girls. Like most second or third sons, he didn't recieve much education, but he was literate and recieved martial training. By 1633, he was definitely in the Musketeers, using his mother's surname to gain status in the regiment.
Not much is known definitely about Charles until 1646. At this point, Louis XIII had died and so had Richelieu. Richelieu's succeessor was Cardinal Mazarin, who advised the Queen Regent Anne of Austria on how to run the state until her infant son, Louis XIV, gained his majority. Charles ended up a beneficiary of Mazarin's patronage from 1646 until his death, starting off as a military courier and climbing the ranks. The reasons to why he did this are unclear. Perhaps he was playing the long game and hoping the minister would triumph. Perhaps he simply admired Anne of Austria. Or perhaps be helieved in being loyal to the nobility, including their first ministers, no matter what (see Honnête Homme). Either way, his loyalty and aptitude distinguished him in Mazarin's esteem.
In 1651, Mazarin was briefly exiled, and Charles was trusted to deliver his letters to Mazarin's network of nobles and spies. When Mazarin's exile ended, Charles was called into active military duty during the new King Louis XIV's campaign to attempt to capture the Spanish Netherlands. He fought honorably and, like other Musketeers (see The Musketeers), was known for taking dangerous missions. He was promoted up the ranks in the army to a captaincy. This allowed him greater access to the King and he was eventually granted a sub-lieutenancy of the Musketeers in 1658. Charles was around 40 and Louis XIV was around 18. This appointment brought him to the attention of the King because Charles oversaw most of the day-to-day activities of the Musketeers- he ran their drills, made sure they were properly outfitted (an enormous financial responsibility), and reported to the King. From this point on he was constantly in debt due to caring for his men.
At the same time as his appointment, Charles married an heiress named Charlotte-Anne de Chanlecy. Their marriage was apparently loveless but they did have two children, fathered between Charles' obligations to the military. At the end of their marriage they separated, but did not divorce.
The next duty Charles was to carry out for the King lasted almost 5 years with little respite. Charles served as the jailer for a disgraced minister, Nicolas Foquet. Though this period was long and wearing for Charles, he never behaved dishonorably. He followed orders with an unwavering loyalty to the monarchy, while still displaying an honorable civility (see Honnête Homme) for Foquet. For example, he asked for and received funds to give Foquet a better bed, "the one he had being insufficient".
Upon returning from his long service as Foquet's jailer, Charles found that the companies of the Musketeers had been separated into two companies- the Black and the Grey Musketeers, named after their horses. Louis XIV had intervened specially to ensure that Charles was the sub-lieutenant of the Musketeers, retaining all of his responsibilities and gaining a new one- the outfitting of his men. As Charles was a poor Gascon nobleman, this was very difficult. Clothes were costly, and no expense could be spared when one was parading in front of the nobility and the King daily. To aid Charles, Louis XIV advanced 10,000 livres (~$150,000) from the war fund in 1667 to help outfit Charles' company of Musketeers.
In 1667 Louis went to war with the Spain based on a claim his wife had to certain lands that Louis wanted. (See France: Recent Military History) Charles and his company of Musketeers were some of the first people to fight. They made a point of charging bravely forth into whatever danger awaited them and prevailing, sometimes through sheer force of will rather than any military strategy. After the fighting ended, Louis, impressed with Charles' service, made him governor of Lille in 1972. This was a mixed blessing- Charles truly loved the army and was never happier than when he was fighting. However, this was a coup for him socially, as it elevated his status as a nobleman. He took the position and spent the next few years in Lille, a newly conquered town rife with anti-French feeling.
In Lille, there was daily conflict between Charles, who cared deeply about this important town's fortifications, and the new fortified citadel builders, who impeded his work defending the existing part of the city. The letters that are left from this period confirm that Charles was a little difficult to work with in his new role. He got into spats almost daily and would write to the War Minister for help. Diplomacy was not his strong suit. However, he was a good governor, protecting the town from Dutch incursion. Finally he was called back to court, where he whipped his Musketeers back into fighting shape.
In 1673, Louis once again went to war, beseiging a Dutch town called Maastricht. Once again, Charles and his Musketeers led the charge. They made Louis and Charles proud- for example, when twenty Musketeers were attacked by two squadrons of enemy cavalry, they succeeded in inflicting heavy casualties and driving them back to inside Maastricht. Only two Musketeers were killed, which (for the time) was amazing. In addition, Charles was the maréchal de camp, or advisor, for the Duke of Monmouth, a prestigious position. Unfortunately, the Duke was inexperienced in matters of war and often disregarded Charles' advice, leading to dangerous situations for Charles' Musketeers.
Charles himself led a group of Musketeers to a highly dangerous area of the fighting, aiming to take an enemy fortification. They were successful, but after 5 hours of fighting, nobody could find Charles. His company braved the fighting again to try to find him. They did- he had been shot through the throat, dying instantly. On top of him he clutched the company standard. His company bore his body back to camp. The King was informed of the death and was deeply distressed by it. He had a funerary Mass said for Charles in his own private chapel.
Charles was well remembered for his dedication to the monarch, his love for his men, and his bravery and honor. One of his most famous epitaphs was written by the poet Juliani de Saint-Blaise: "D'Artagnan and la gloire have the same coffin." Undoubtedly this is how he would have liked to be remembered.