Inspector Uhl (Paul Giamatti) finds a gem from Prince Leopold's (Rufus Sewell) sword and Sophie's (Jessica Biel) necklace at the stable. With this evidence, he's convinced that the prince murdered Sophie. He confronts the prince and he says that it's all Eisenheim's (Edward Norton) doing and that it's all a trick. Uhl mentions that he wrote to the prince's father, the Emperor, telling him what's happened and just as the Emperor's guards are approaching, the prince shoots himself. Eisenheim, in disguise, heads to the train station. A little boy gives to inspector Uhl the instructions to the orange tree illusion and he suddenly realizes that Eisenheim's acts really are illusions and are not real. He heads to the train station, hoping to catch Eisenheim and he figures it all out. The "physician" that inspected Sophie's "corpse" is really a friend of Eisenheim (he appears when Uhl is following and eavesdropping on Eisenheim before he reports to the prince that he saw Sophie with Eisenheim). Sophie faked her death and took some kind of drug so that she would look dead, Eisenheim took a gem from the prince's sword on the night that he did the "sword in the stone" trick. Sophie drugged the wine before being "murdered" and she put blood on the horse. Uhl smiles now that he's realized that Eisenheim fooled everyone. The last scene is Eisenheim and Sophie happily reunited...
Alex
Answer: Although the story is fictional, some of the details are based on the life of Austrian Crown Prince Rudolf, only son of Emperor Franz Josef. The painting of the emperor which Eisenheim creates is an actual portrait of Franz Josef. (from IMDb).