The Warlock in Spite of Himself is a science fantasy novel by American author Christopher Stasheff, published in 1969. It is the first book in Warlock of Gramarye series. The title is a play on the title of Molière's Le Médecin malgré lui (The Doctor, in Spite of Himself).
As the Vietnam War continued, Stasheff's novel clothed his thinly veiled commentary about the proper uses of government and democracy in a fantasy about interstellar travel, fairies, unusual flora and refugees fleeing persecution.
The novel centers around Rod Gallowglass, a SCENT agent, who stumbles across the planet Gramarye. Immediately upon landing he is thrust into a world of medieval people, witches and warlocks, and all manner of mythical creatures. Rod is aided by his faithful companion Fess, an epileptic robot. While gathering intelligence, Rod discovers the planet is in political turmoil, due to futurian influence on behalf of the PEST and VETO organizations who plan to corrupt the planet away from democracy, which Rod plans to bring to the planet, due to the planet's importance to the future of the DDT. The three main factions are the Monarchy led by Queen Catherine, the beggars led by Tuan Loguire, and the Noble Lords eventually led by Anselm Loguire.
Unfortunately for Rod when going to an inn for the night he is attacked by Big Tom. Rod defeats him, almost too easily, and Big Tom becomes a squire for Rod. Shortly thereafter the "wee people", who saw him land, declare him a warlock and put him to a test if he is good or evil by forcing him to fight a werewolf. Upon defeating it, with garlic sausage, he is returned to the inn he was staying at. The next day Rod and Tom head to Catherine's castle to get themselves positions as soldiers. To do this however Rod is caught up in a fight with Brom O'Berin, a dwarf who is advisor to the Queen. Though defeated, Rod is permitted to join the Queen under the promise the solve the mystery of the Banshee which continuously is spotted upon the castle battlements, Rod discovers it to be a hologram machine set upon the castle roof, he quickly disables it and is sent out for his next mission.
Rod is then sent to gain intelligence on the Lords who have assembled at the fortress of Duke Loguire. On his way to the fortress Rod encounters a witch of his own age named Gwendylon. Gwen and Rod fall in love but Big Tom tells Rod he should stay away from her. Passing themselves off as minstrels they gain entrance to the fortress and find the old Duke losing his grasp on the other lords. Rod discovers each lord has a new advisor, who are PEST agents. Rod seeks more answers by exploring the haunted areas of the fortress and he encounters ghosts. Thanks to Fess the ghosts give up trying to stop Rod and allow him free access. Rod discovers a passageway behind the Duke's seat in the great hall, which he later uses to save the Duke when the lords turn on him. However the ghosts discover that Gwen had followed Rod and return her to him. Upon saving the Duke, who is then replaced by his son Anselm, they make their escape into the forest and back to the Queen's castle. However, not having the full story, the Queen imprisons the old Duke Loguire for high treason and attempts to imprison Rod and Tom for aiding him until Brom comes to their aid and Cathrine lets them free.