The Celestial Toymaker is an immortal being of enormous power, existing in a domain altogether separate from our own. He draws passing travellers into his domain, the Celestial Toyroom, and forces them to play games for him. And if the traveller is unlucky enough to lose the game - as most do - then they become one of the Toymaker's playthings.
The Toymaker primarily dwells in his eighteenth-century study, which is filled with a variety of toys, games and dollhouses, as well as a collection of clocks. Aside from his intense fixation on games, the Toymaker seems also to be fond of Chinese culture; various Chinese objets d'art decorate his study, and he himself dresses like a Chinese mandarin, in ornate robes and a circular hat. He has a very powerful mind, largely because the Toymaker controls everything that happens within his domain. Among his powers are the ability to teleport within his domain, turn people invisible, intangible, and unable to speak, and his mind can even penetrate the TARDIS' safety barrier, which few other beings can do. He also possesses a hypnotic memory window, which reveals scenes from the past of the person looking into it.
The Toymaker keeps his playthings - mostly visitors to his domain who lost his game and have been turned into dolls or playing cards - scattered around his study and stored in his many dollhouses. When he wants to use them in one of his games, the sapphire ring on his left hand can turn them back into people. The Toymaker promises them their freedom if they win the game for him and defeat their opponent (although there is no indication that he would actually keep his promise - particularly as his initial deal is that if they lose the game he sets before them, they are to become his toy forever), but if they lose, they simply turn back into their previous toylike state. But because they are actually real people, and not merely toys that the Toymaker created, his playthings have wills and minds of their own, and human foibles; presumably the Toymaker believes that this makes his games more interesting.
At the Doctor's first visit to the Toymaker's lair, the Toymaker hoped he might stay to play a game, but the Doctor quickly turned around and left. Since then, the Toymaker has been waiting for the Doctor to return, and when he does, the Toymaker forces him to stay and play his games by stealing his TARDIS. He instructs Steven and Dodo to play a series of games after which, if they win, they will regain the TARDIS; meanwhile, he gives the Doctor the challenge of solving the trilogic game in exactly 1,023 moves, with the caveat that Steven and Dodo must finish their set of games first. In the trilogic game, the Doctor is presented with a pyramid of puzzle pieces which are then separated into three smaller piles; the Doctor must reassemble the pyramid by moving one piece at a time, without putting any larger pieces on a smaller one.
While the Doctor is busy working at the trilogic game - with the Toymaker advancing his game forward every time the Doctor displeases him, giving his companions less time to finish their games - Steven and Dodo work at solving the puzzles the Toymaker sets before them. A robot stands nearby to show them the Doctor's current number of moves on a monitor in its body.
First, Dodo must help a blindfolded Steven navigate an obstacle course with only the use of a buzzer to signal directions. Their opponents are two clowns who cheat by rearranging the obstacle course as Steven goes through it. When Dodo discovers that one of the clowns cheated by using a fake blindfold, they demand that he redo the course - at which he fails, causing the clowns to turn back into dolls and allowing Steven and Dodo to continue on to the next test. The Toymaker supplies them with a "helpful" riddle before each subsequent game.
Their next task, for which they are pitted against the King, Queen and Jack of Hearts and their Joker, is to figure out which of seven chairs is safe and will allow them to continue; the other six are booby-trapped in a variety of deadly ways. Fortunately, Steven and Dodo find several life-size dolls which they can use to test the chairs. One chair shakes the occupant to death, one is wired for electrocution, one dematerializes the occupant, one contains a whirring blade that slices the occupant in half, one freezes the occupant to death, and the last collapses violently. When all the chairs have been eliminated, as well as the King and Queen (and almost Dodo), they continue on to the next test.
Here Steven and Dodo must find a hidden key in the kitchen of Mrs Wiggs, with the help of Sergeant Rugg. The key lets them on to a deadly dance floor populated by three dancing dolls; once on the floor, it is impossible not to continue dancing, particularly as the dolls partner up with anyone who treads on the floor and are not inclined to let go.
Steven and Dodo's final test is a game of TARDIS hopscotch versus a conniving English schoolboy named Cyril, who is armed with slippery powder and sneaky tricks to get people to move off their square and be sent back to the start. One large catch: the floor between the squares is electrified, making any misstep deadly.
In the end, Steven and Dodo manage to finish their tasks just as the Doctor solves the penultimate move of the trilogic game. But the Doctor now faces a dilemma - because the Toymaker is immortal, having lasted for thousands of years, from time to time he does lose a game, and when this happens he has to pay the price. The particular cost in question is the loss of his domain. This is not an enormous problem for the Toymaker, as he can simply construct a new one; but he is a sore loser, and always destroys the person who destroys his domain, by ensuring that they are in his domain when it vanishes. The Doctor solves this final puzzle by using the loudspeaker from inside the TARDIS, and imitating the Toymaker's voice to make the final piece of the Trilogic game move. As the Toymaker's domain vanishes, the TARDIS dematerializes, and the Doctor and his companions are free.
The Toymaker was supposed to return in the first story of the original, aborted, twenty-third season. In this episode, entitled The Nightmare Fair, the sixth Doctor takes Peri to a funfair at Blackpool, where the Toymaker is capturing fair visitors to build and test a deadly video game - when a player loses, one of the game monsters comes out of the game to kill them. This story would have revealed more about the background of the Toymaker, but as it was never filmed, its canonicity is subject to debate.