In Vienna, Austria-Hungary, 1889, a magician named Eisenheim is arrested by Chief Inspector Walter Uhl of the Vienna Police during a magic show involving necromancy. Later, Uhl explains the story of Eisenheim’s life to Crown Prince Leopold.
Eisenheim was born to a cabinet-maker and became interested in magic after meeting a travelling magician. He also fell in love with Sophie, the Duchess von Teschen, but the two were forbidden to see each other on account of the former being a peasant. They kept meeting secretly but were caught one day and separated by force. Eisenheim proceeded to study magic by travelling the world, and fifteen years later returned to Vienna to perform. During one performance, he encounters the adult Sophie and learns that she is expected to marry the Crown Prince Leopold, who, it is rumored, is brutal towards women and in the past even murdered one. Eisenheim conducts a private show for the Crown Prince and humiliates him in the course of it. In response, he is banned from performing again in Vienna. After the show, when Sophie comes to offer him help, they argue before surrendering to their feelings and making love. Eisenheim asks Sophie to flee with him, but Sophie is afraid that they will be hunted down and executed. Sophie also reveals that the Crown Prince is planning a coup d’etat against his elderly father, the Emperor Franz Joseph I.
At the Mayerling hunting lodge, Sophie tries to end her engagement with Leopold. He reacts by chasing her into the stables with a sword, in full view of the servants. Sophie’s body is discovered the next morning in the Vienna Woods, an unknown man blamed for her assassination. This throws Eisenheim into a deep depression. He eventually buys a theatre and begins a new series of magic shows, this time focusing exclusively on the summoning of dead spirits. Leopold secretly attends one of them, during which Eisenheim summons the spirit of Sophie, who says that someone in the theater is her murderer. Leopold, highly unnerved, orders Uhl to arrest Eisenheim for fraud, but Eisenheim manages to avoid jail by openly confessing to the public that his show is a mere illusion.
Eisenheim is threatened that if he summons Sophie in his next performance, he will be arrested and likely imprisoned. Uhl attends the packed performance with dozens of officers, and in spite of the warnings, Eisenheim brings Sophie’s spirit to life again. Uhl storms the stage with his officers, but to the shock and horror of the audience, Eisenheim is revealed to be a spirit when Uhl’s hand passes through him. Eisenheim then fades away in front of everyone.
Uhl reveals to Leopold that he has found evidence—a jewel from Leopold’s sword and Sophie’s distinctive locket—which could implicate Leopold in Sophie’s murder. Uhl has already informed the Emperor and the Austro-Hungarian General Staff of Leopold’s conspiracy to seize the throne. Leopold points a revolver at Uhl, threatening to kill him, but as officers of the imperial guard of the Austro-Hungarian Army arrive, Leopold shoots himself in the head. Later, as Uhl leaves the palace, he places Sophie’s locket in his pocket. He is now no longer Chief Inspector of Police. As a boy approaches him, he is jostled by a bearded man in a long coat. The boy gives him a package containing Eisenheim’s notebook about the Orange Tree trick, which Uhl had been unable to figure out. He asks the boy who it was that gave him the notebook, and the boy replies “Herr Eisenheim.” He checks his pocket and realizes the person who jostled him stole the locket. He sees the man and chases after him, but the man boards a train and escapes. Uhl realizes the jostling and the notebook are a message from the illusionist, and begins to rethink recent events. He concludes that Sophie and Eisenheim staged her death so that she could be free of Leopold. Uhl laughs delightedly at the brilliance of their plan. Later, and far away, Sophie and Eisenheim start a new life together in a cabin at the foot of a beautiful mountain. Eisenheim places Sophie’s locket in her palm.