Sourcery is the fifth Discworld novel by Terry Pratchett, published in 1988. On the Discworld, sourcerers – wizards who are 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 are wizards squared. To prevent the creation of sourcerers, therefore, wizards are not 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.
Ipslore the Red is a wizard who is about to die. Death comes to usher Ipslore's soul into the next world as the story begins. Ipslore tells Death about his banishment from the Unseen University because he married and had children, something forbidden for wizards. Throughout the scene he is holding his infant son, whom Ipslore names Coin. Coin is Ipslore's eighth son, a Wizard squared – a source of magic: a "sourcerer". Ipslore plans to determine Coin's destiny and force him to take revenge upon the wizards, but Death forces him to leave a chance for Coin to not follow this fate as the universe demands a loophole; Ipslore states that fate will have its chance when Coin throws his staff away, Death conceding to the possibility of such an action. As Death is about to take Ipslore to wherever lies beyond, Ipslore transfers his essential being into his staff, which Coin has accepted, thus ensuring that Death cannot cut him loose without destroying the staff and disrupting Ipslore's prophecy. In this way, Ipslore plans to teach his son and ultimately make him Archchancellor of Unseen University.
Some years later, Virrid Wayzygoose is about to be elected as Archchancellor of the Unseen University. Unfortunately, he is caused to disappear before he can be proclaimed by an unseen attacker. Shortly afterwards, Coin gains entry to the Great Hall in UU and, after besting one of the top wizards in the University is 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 Virrid Wayzygoose. The hat, having been worn on the heads of hundreds of Archchancellors, has gained a kind of sentience and is able to enlist both Conina and Rincewind to take it to Al Khali, far away from Ankh Morpork and the University. The Librarian is not enlisted as he is buying a round at the bar, although the Luggage comes along for reasons of its own.
While en route to Al Khali, the ship in which they are travelling is attacked by pirates and in the ensuing fight the hat is lost. Thinking that the pirates would probably take the hat to Al Khali, they decide to follow the pirates and retrieve the hat. Several misadventures later, Rincewind, Conina and the Luggage are captured by Abrim, the Grand Vizier to Creosote, the Seriph of Al Khali. Rincewind is thrown into the snake pit, where he meets Nijel "the Destroyer" a barbarian hero who has been on the job for three days and wears wooly underwear because he promised his mother he would. Conina is taken to the harem, where she is called by Creosote and asked to tell him a story. (Rincewind, upon finding this out, suggests that telling stories in a harem will "never catch on"). The Luggage, having been scorned by Conina, has run away and kills and eats several creatures in the deserts.
Back 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 and make plans to take over the world. Coin declares UU obsolete and orders the Library to be burnt down, claiming that Wizardry no longer requires such things.
Meanwhile, Creosote has joined Rincewind, Conina and Nijel. 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 many previous Archchancellors, the hat proves an even match for Sourcery empowered wizards, fighting off a group of them and enlisting others to its cause. Across the world, wizards start building towers and going to war with one another, slowly weakening the Disc itself. Rincewind, Conina, Nijel and Creosote make their way into the treasury, where they find a magical flying carpet, and escape the palace as it gets destroyed by the possessed Abrim building his own tower.
Upon hearing the rest of the group express anti-wizard sentiments, an angry and humiliated Rincewind abandons them, taking the flying carpet and making his way to the University. He soon learns that the Librarian has saved the books by hiding them in the ancient Tower of Art. After some discussion with the Librarian, Rincewind goes off to face the Sourcerer with a sock containing a half-brick. At about the same time, the Ankh-Morpork tower emerges victorious in the wizard wars, but Coin is concerned when he is told that wizards rule under the Discworld Gods. Coin traps the Gods in an alternate reality, which shrinks to become a large pearl. The Gods being trapped causes the release of the Ice Giants from their prison and they begin strolling across the Discworld, freezing everything in their path.
Rincewind confronts Coin soon after this. The Sourcerer is amused by Rincewind attempting to fight him with a half-brick in a sock, prompting Ipslore to try and force Coin to kill him despite Coin considering Rincewind to be funny rather than an actual threat. Rincewind eventually convinces Coin to throw the staff away, but Ipslore's power is channelled against that of his son. The other 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 other 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.
Coin returns the University to its former glory (his offer to make everything as good as new is rejected by the Librarian, who asks him to restore everything so that it is as good as old). Recognising that he is too powerful to remain in the world, Coin steps into a dimension of his own making, closes the dimension and is not 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. However, he thought that it might work better as a film, and that he could have fun with characters like Nijel the Destroyer.