Theater financier Spencer Lockridge is at the den of his country home in Greenhaven. He tells a visitor that he won't let anything spoil his nephew's weekend and that they should decide what is really important before Lockridge decides for them. The visitor leaves and Spencer dons his Mad Hatter costume.
Ellery and his agent, Howard Biggers, take the train to Spencer's estate and argue over who will be the victim in Spencer's theater adaptation of Ellery's mystery novel. The conductor overhears them and assumes the worse. Howard and Ellery take a taxi to the estate and Ellery wonders why Spencer wants to rewrite his book. The agent assures him that's how it's done on Broadway, and tells Ellery that they're going to the estate to meet with Spencer because he's hosting a birthday party for his nephew, Johnny.
When the two men arrive at the estate, the butler, Doyle greets them and explains that one of the guests, Paul Gardner, can't find his ears. Ellery soon realizes that Paul and the other guests are playing the part of characters from Alice in Wonderland. Paul is an architect and helped build Spencer's new home. Spencer's wife Laura is the Dormouse and Broadway actress Emmy Reinhart is playing Alice. Emmy claims to be a big fan of Ellery's work and runs over to him. Also present are Paul's wife Diana and Spencer's mother-in-law, Letitia.
As they go to the living room for drinks, Letitia complains about how her son-in-law is using her money to finance his new home and his Broadway plays. Meanwhile, Spencer tells Ellery that Emmy will be playing the female lead in the play, much to Ellery's dismay. When the writer objects, Spencer agrees to find someone else if Ellery will break the news to Emmy. When Emmy comes back, Ellery can't bring himself to do it. The actress flirts with him, suggesting they discuss his novel in private, and Ellery hastily leaves to go to bed.
Later that night, a storm is coming down and Ellery wakes up at 2 a.m. Unable to get back to sleep, Ellery goes to the library to get a book. He enters Spencer's den by mistake and discovers that the light switch doesn't work. As he steps out into the hallway, an armed Doyle confronts him. The butler explains that he also works as Spencer's bodyguard and people have threatened the financier's life. As Ellery goes upstairs, he meets Paul coming downstairs Emmy is also prowling around and hears them talking. She greets Ellery and goes back to her room, and Paul and Ellery go to their rooms as well as Doyle turns off the lights.
The next morning, Johnny storms into Ellery's room and tells the writer that his uncle has disappeared. Ellery goes to the library to meet the others. Laura tells them that Spencer never came to bed and is apparently still wearing his Mad Hatter costume. The only two cars are still there and Spencer couldn't have called a taxi because the storm knocked out the telephone lines. Ellery suggests that they split up and search the house, and the others wonder if they should call the police. Howard advises against it, noting that they don't even know if something bad has happened. Ellery goes to Spencer's den and notices a phosphorescent Cheshire Cat clock on the wall. The light switch now works and Ellery turns the light on and off. He then climbs up to examine the clock as Emmy comes in to find him. When she wonders what he's doing, Ellery explains that someone must have moved the clock.
Everyone returns to the library and Ellery explains that during the previous night he entered the den by mistake. The light didn't come on but he didn't see the phosphorescent clock in the dark. The writer concludes that the intruder unscrewed the light bulb and froze in the darkness, blocking a mirror on the opposing wall that would have let Ellery see the clock. Ellery suggests that kidnappers are involved and wants to call the police, but Laura warns that could endanger her husband if he's right. The writer admits that there are three possibilities: Spencer wandered off, was kidnapped, or was murdered.
Once Ellery finds himself alone, he calls Inspector Queen and him order a three-state alert for a man dressed as the Mad Hatter. Johnny finds Ellery and suggests that Laura hired two men to kidnap Spencer, collect the ransom, and then kill him. Laura wouldn't get the ransom money, but she would inherit Spencer's fortune. Johnny also points out that Laura is having an affair with Paul.
Outside the house, Laura and Paul meet. Paul explains that they shouldn't feel guilty about their affair since he and his wife are estranged, and Spencer never loved Laura. Ellery comes out and spots them together as Paul tries to kiss Laura. As Laura goes, Paul admits that he's having an affair with her and doesn't care that Ellery knows. The architect leaves and Ellery studies the estate's lawn as Emmy comes out. She doesn't believe that Spencer would have wandered off on his own because of his fear of kidnappers. Ellery studies the lawn, ignoring her, and goes back into the house.
In the living room, Ellery tells the assembled guests that they should wait one more day before calling the police. Emmy accuses Howard of kidnapping Spencer, pointing out that the financier kept Howard working for him for years. Howard responds by accusing Emmy, explaining that Spencer held her to her contract and kept her from getting any roles. Emmy responds by insisting she didn't want the roles anyway. Laura starts to leave but then collapses. Ellery looks at his coffee and then collapses as well.
The next morning, Ellery wakes up and discovers that everyone else drank drugged coffee as well and passed out, including Doyle in the kitchen. Emmy wakes up and Ellery explains what happened, and then goes out to the wet lawn. As he walks toward the surrounding trees, Johnny comes out and Ellery warns him away. The boy explains that Doyle was his uncle's bodyguard, not a butler, and keeps complaining about Ellery's detectives techniques until the arriver threatens to give him a switching.
When Ellery returns to the den, everyone is arguing. He explains that whoever drugged them must have wanted them alive since he could have easily killed any of them. The writer asks the guests to wait until noon and promises to contact the authorities then if Spencer doesn't turn up. As the others go to breakfast, Ellery asks Laura where she and Spencer kept their valuables. Spencer's wife explains that Spencer kept their valuables in storage because he didn't trust banks. He planned to have a custom-made safe installed. Ellery gives her the exact dimensions of the safe, much to Laura's surprise, but refuses to explain how he knew. Laura admits that she had no idea where her husband was going to place the safe and leaves. Once she's gone, Ellery makes a phone call.
Grace informs her boss, Inspector Queen, that the police have had no luck finding Spencer. He asks her to call in Velie, but she tells him that Velie logged out even though he's supposed to be on duty. The Inspector tells her to call Inspector Carr from the 115th Precinct.
Ellery goes to see Doyle and points out that Spencer was his responsibility. However, the "butler" claims to have no idea what Ellery is talking about. Emmy comes to see Ellery and concludes that Spencer hasn't been kidnapped. Ellery admits that he hasn't, but avoids saying whether he's dead. As they talk, the doorbell rings and Diana answers the front door. There's no sign of anyone, but there is a package on the step addressed to Laura. Inside they find a pair of Spencer's shoes, but a different pair then the ones he wore the night of the party.
As the assembled guests examine the shoes, there's a knock at the rear door. Doyle finds a package addressed to Emmy. Inside it are two model ships, gifts that Paul gave to Johnny for Christmas. Letitia confirms that Johnny, although absent, has been in his room all morning and can't be planting the packages. They split up to search the house, and Ellery and Emmy find an envelope addressed to Letitia. She opens it but there is nothing inside. She does confirm that the stationery is her own and the wax seal on it is one she uses for her personal correspondence. When they check her desk, they confirm that the stationery and wax has been stolen.
A frantic Laura insists that they call the police, but Ellery assures her that he already has. Inspectors Queen and Carr arrive and Ellery invites them in. As Ellery starts to explain to them what is happening. Howard finds a basket on the porch addressed to Paul. Inside of it are two cabbage heads.
Ellery calls everyone into the library and reminds them of what they've found: shoes, ships, sealing wax, and cabbages. Carr figures that someone is playing a joke and Inspector Queen asks Ellery where Velie is. As they talk, someone throws a rock through the window. It has a note addressed to Laura and the wrapping around it contains two chess pieces: the black and white kings. As the others argue, Ellery slips out of the room and Emmy follows him. He goes to the study and then comes back out, and tells Emmy that he was setting up chairs for a performance. Ellery informs her that Spencer is dead, much to her regret since he's the only one who ever gave her a chance. The writer asks her not to tell the others but to invite them into the study for the denouement.
Once everyone gathers in the study, Ellery tells them that Spencer is dead. He explains that when he entered the study, he didn't see the glow-in-the-dark cat in the mirror. From that he initially assumed that someone was blocking it in the dark. However, Ellery soon realized that the killer would have to be 7' tall to block the clock's reflection. That means that if someone didn't block the mirror, the mirror must have been moved. Letitia points out that the mirror is too large to be moved and that it's fastened to the wall, and Ellery agrees. He then moves on to the clues: shoes, ships, sealing wax, cabbages, and finally... kings. Ellery reminds them that those objects are all found in a line written by Lewis Carroll as spoken by the Walrus. Emmy recognizes the line, but Ellery points out that it's not from Alice in Wonderland, but from the sequel... Through the Looking Glass, and What Alice Found There. Ellery goes to the mirror, activates a hidden catch, and the glass slides aside to reveal a hidden compartment. Inside is a corpse dressed as the Mad Hatter. Paul breaks down and says that it's not possible because he buried Spencer by the south gate. Ellery thanks him for confessing and the "Mad Hatter" gets up. It's Velie, posing as Spencer.
Later, Ellery, his father, and Emmy are taking the train back to New York. Ellery explains to them that he eventually found the catch to open the mirror and the secret compartment where Spencer intended to put his safe. Ellery suspected that Paul was the killer because he renovated the house for Spencer. Paul killed Spencer the night of the party after everyone went to bed. Before he could take the body outside, Ellery came downstairs and accidentally entered the study. Paul had no choice but to open the mirror and hide Spencer's body, preventing Ellery from seeing the clock's reflection. Paul then snuck out and went upstairs, and then came downstairs to meet Ellery. Since it was raining, Paul couldn't bury the body on the grounds that night. He drugged the coffee the next day after the rain had stopped and the n buried Spencer's body. When Ellery searched the grounds and couldn't find the body, he called Velie, had him plant the Wonderland clues, and then pretend to be Spencer's corpse to rattle the murderer into confessing. As Ellery talks about the murder, and then starts discussing his novel, the conductor overhears them again.