Sourcery is the fifth Discworld novel by Terry Pratchett, published in 1988. On the Discworld, sourcerers – wizards who're sources of magic, and thus immensely more powerful than normal wizards – were the main cause of the great mage wars that left areas of the disc uninhabitable. As eight is a powerful magical number on Discworld, men born as the eighth son of an eighth son are commonly wizards. Since sourcerers are born the eighth son of an eighth son of an eighth son, they're wizards squared. To prevent the creation of sourcerers, therefore, wizards aren't allowed to marry or have children. The first few pages of the novel deal with a sourcerer's father who cheats death by making a prophecy that Death must honour; the alternative is to risk destroying the Discworld. The rest of the novel deals with the sourcerer's plan to have wizards rule the Discworld, and the efforts of a small group – including Rincewind the Wizzard, Nijel the Destroyer and Conina the Hairdresser, daughter of Cohen the Barbarian – to thwart those plans.
Death comes to gather the soul of Ipslore the Red, a wizard who was banished from Unseen University for marrying and having children, something forbidden for wizards. Bitter over this fate, Ipslore vows to take revenge upon the wizards through his eighth son, Coin. As the eighth son of a wizard, Coin is born a sourcerer, a wizard who generates new magic rather than drawing it from the world, effectively making him the most powerful wizard on the Disc. At the moment of his death, Ipslore transfers his essential being into the infant Coin's staff, preventing Death from collecting his soul and allowing him to influence his son.
Eight years later, Virrid Wayzygoose, the next Archchancellor of Unseen University, is murdered by Coin, who then forces his way into the university's Great Hall. After Coin bests one of the top wizards in the University, he's welcomed by the majority of the wizards. Rincewind, The Luggage and the Librarian miss Coin's arrival, having fled the University shortly beforehand. While at the Mended Drum, Conina, a professional thief and a daughter of Discworld legend Cohen the Barbarian, arrives holding a box containing the Archchancellor's hat, which she has procured from the room of Wayzygoose, and possesses a kind of sentience as a result of being worn by hundreds of Archchancellors. Under the direction of the hat, which sees Coin as a threat to wizardry and the quite world, Conina forces Rincewind to come with her and take a boat to the city of Al Khali, where the hat claims there's someone fit to wear it.
In Ankh-Morpork, the wizards are made more powerful due to Coin's presence drawing more magic into the Discworld. Under Coin's direction, the wizards take over Ankh-Morpork, transforming it into a pristine city, and make plans to take over the world. Elsewhere, Rincewind, Conina and the Luggage end up in the company of Creosote, the seriph of Al Khali, and Abrim, his treacherous vizier. The trio are eventually separated; Rincewind is thrown into the snake pit, where he meets Nijel the Destroyer, a barbarian hero in training. Conina is taken to Creosote's harem, where the Seriph has his concubines tell him stories. The Luggage, having been scorned by Conina, runs away and gets drunk, before killing and eating several creatures in the deserts.
Coin eventually declares Unseen University and the various wizarding orders obsolete and orders the Library to be burnt down, claiming that Wizardry no longer requires such things. A group of wizards then attack Al Khali, the sheer amount of magic created by their arrival temporarily putting Rincewind into a trance and enabling him to use magic, allowing him and Nijel to escape the snake pit. They join up with Creosote and Conina, the latter immediately falling in love with Nijel, and they encounter Abrim, who had put on the Archchancellor's hat hoping to gain power from it, only to be possessed instead. Having the experience of a large number of previous Archchancellors, the hat proves an even match for Sourcery empowered wizards, fighting off a group of them and enlisting others to its cause. As this takes place, Rincewind, Conina, Nijel and Creosote find a magical flying carpet in the palace's treasury, and use it to escape the palace as it gets destroyed by the possessed Abrim building his own tower.
With the orders no longer around to keep the wizards in check, wizards across the Discworld go to war with one another, threatening to destroy the world completely. Upon hearing Creosote express anti-wizard sentiments, an angry and humiliated Rincewind abandons the group, taking the flying carpet and making his way to the University, where he learns that the Librarian has saved the library books by hiding them in the ancient Tower of Art. The Librarian convinces Rincewind to stop Coin, and he goes off to face the Sourcerer with a sock containing a half-brick. Back in Al Khali, the Luggage, blaming the Archchancellor's hat for everything it has endured, forces its way into Abrim's tower. Distracted by the Luggage, the possessed vizier is killed by the Ankh-Morpork wizards, with the tower and the Archchancellor's hat getting destroyed in the process.
Despite his victory, Coin becomes concerned when he's told that wizards rule under the Discworld Gods. He traps the gods in an alternate reality, which shrinks to become a large pearl, unknowingly causing the Ice Giants, a race of beings who had been imprisoned by the gods, to escape their prison, whereupon they begin strolling across the Discworld, freezing everything in their path. Rincewind confronts Coin soon after this. The Sourcerer is amused, but unthreatened, by Rincewind attempting to fight him, prompting Ipslore to try and force Coin to kill him. Rincewind eventually convinces Coin to throw the staff away, but Ipslore's power is channelled against that of his son. The additional wizards leave the tower as Rincewind rushes forward, grabbing the child and sending both of them to the Dungeon Dimensions whilst Death strikes the staff and takes Ipslore's soul. Rincewind orders Coin to return to the University and, using his additional sock filled with sand, attacks the Creatures from the Dungeon Dimensions as a distraction to ensure Coin's escape. The Gods are subsequently set free, stopping the march of the Ice Giants. As the Librarian helps Coin escape, the Luggage charges into the Dungeon Dimensions after Rincewind.
Coin returns the University and Ankh-Morpork to the way they were before he came. After Conina and Nijel travel to the University looking for Rincewind, Coin uses his magic to make them forget him and live happily ever after together. Recognising that he's too powerful to remain in the world, Coin steps into a dimension of his own making, and isn't seen on the Discworld again. The Librarian takes Rincewind's battered hat, which got left behind when he went into the Dungeon Dimensions, and places it on a pedestal inside the Library.
In 2010, Terry Pratchett stated that Sourcery would be the fifth Discworld novel to be adapted for Sky One, although he had initially wanted to adapt Making Money. Notwithstanding he thought that it might work better as a film, and that he could have fun with characters like Nijel the Destroyer.