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 have missed the arrival of the Sourcerer and are in the pub. While there, Conina, a professional thief, 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.
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.
Coin has shown the wizards the ways of Sourcery and declared UU obsolete. The Library is burned down. Wizardry no longer requires such things. However, Coin is concerned when he is told that Wizards now 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. War, Famine, Pestilence and Death are about to release the Apocalypse. The Discworld is about to end.
Meanwhile, Creosote has joined Rincewind, Conina and Nijel in their attempts to find a way to Ankh Morpork to face the Sourcerer. They make their way into the treasury, where they find a magical flying carpet, and escape the trembling palace, from which half the bricks were leaving, due to the arrival of Sourcery. Rincewind gets separated from the rest when he takes the flying carpet and makes his way to the University, where he finds, thunderstruck, that the Library has been burned down. After having cried over the wreckage for a while, he senses, to his relief, a magical movement up in the Tower of Art.
He realizes 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 in it. Rincewind swings the sock at Coin's staff, sending it straight over the edge of the Tower of Sourcery, but the staff, rising up, attacks Rincewind, clubbing him hard on the side of the head. The staff allows Coin to once more take it into his hands, and orders him to kill the man. Rincewind says, "You don't have to", and Coin throws the staff away, defying his dead father. A third time it comes back into his hands, but both the boy and his father channel power into each other, certain to cancel each other out. Rincewind suggests to the other wizards to help the boy, but the faculty, always out for themselves, leave the tower. Their cowardly decision leaves Rincewind with his own: He rushes forward into the fire, lunging out and grabbing the child… and sending both Coin and himself to the Dungeon Dimensions. Then 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.
The Apocalypse is foiled when Creosote, Nijel and Conina steal three horses from outside a pub. The horses belong to War, Famine and Pestilence. Binky is not stolen, and Death rides off, leaving the other three behind. Short of anything else to do, War, Famine and Pestilence go back into the pub.
Coin returns the Universtity 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). Then 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.