For the Love of Evil by Piers Anthony, sixth book of the Incarnations of Immortality series.
.... Parry discovers that a new order, the Dominicans, are being formed with the express purpose of rooting out evil and heresy. Because of his keen mind and magical prowess (which he uses in secrecy), he becomes a feared inquisitor. During one of his many trips to stop Lucifer's campaign of Evil, Parry succumbs to the temptation of his ghostly wife Jolie inhabiting a physical body, thus violating his oath of celibacy.
As retribution, Lucifer sends forth Lilah (alternately known as Lilith), a demoness, to corrupt him. By using the toehold of his broken oath of celibacy and his own feelings of sexual desire and guilt, Lilah corrupts Parry to Evil. His intense desire for Lilah eventually leads him to corrupt the Inquisition itself. Upon his deathbed, Lucifer attacks Lilah; with his last vestige of strength, Parry manages a magical counterattack against Lucifer, saving Lilah. Lucifer, taken off guard, is defeated. Though Parry's magic was far weaker than that of Lucifer, his spell was able to work because Jolie's good spirit (which still resided in the drop of blood on Parry's wrist) was immune to Lucifer's powers. As a severely weakened Parry lays dying with only moments to live, Lilah tells him to claim the office before it finds a different successor, as well as to name the form he would like to assume (he chooses his body at the age of 25). Parry, not understanding what she's asking of him and wanting to honour this last wish before he succumbs to death, does as Lilah requests, and is suddenly transformed into the new Incarnation of Evil and takes the name Satan. (It is later explained that if no one claims the office, it seeks out the most qualified person for that position. So if Parry hadn't claimed the office as Lilah had told him, it would have found the most evil person on earth to take Lucifer's place.)