Sourcery is a fantasy story set in the fantasy land of Discworld and following the adventures of Rincewind the wizard as he seeks to prevent the rise of a government of powerful magi. The title character, the Sourcerer, or source of magic, named Coin, is guided by his father's malignant spirit to seek revenge on mundane wizards. He is, however, conflicted about his nature as a fountain of magical power. In the end he is redeemed and departs Discworld forever.
Death comes to collect 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 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 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 very world, Conina forces Rincewind to come with her and take a boat to the city of Al Khali, where the hat claims there is 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 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. 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 is 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 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. 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 is too powerful to remain in the world, Coin steps into a dimension of his own making, 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.