The film is named after a segment in Disney's non-consecutive film pair the 1940 film Fantasia and the 1999 film Fantasia 2000 called The Sorcerer's Apprentice starring Mickey Mouse (with one scene being an extensive reference to it), which in turn is based on the late-1890s symphonic poem by Paul Dukas and the 1797 Johann Wolfgang von Goethe ballad. Balthazar Blake (Nicolas Cage), a "Merlinean", is a sorcerer in modern-day Manhattan, fighting against the forces of evil, in particular his nemesis, Maxim Horvath (Alfred Molina), while searching for the person who will eventually inherit Merlin's powers ("The Prime Merlinean"). This turns out to be Dave Stutler (Jay Baruchel), a physics student, whom Balthazar takes as a reluctant protégé. The sorcerer gives his unwilling apprentice a crash course in the art and science of sorcery, in order to stop Horvath and Morgana le Fay (Alice Krige) from raising the souls of the evil dead sorcerers ("Morganians") and destroying the world.
In Britain 740 AD, Merlin has three apprentices; Balthazar Blake, Veronica Gorloisen, and Maxim Horvath. Horvath betrays Merlin by allying with the evil sorceress Morgana le Fay. Morgana mortally wounds Merlin before Veronica rips Morgana's soul from her body and absorbs it into her own. As Morgana attempts to kill Veronica from within, Balthazar stops her by imprisoning Morgana and Veronica in the "Grimhold", a magic prison in the shape of a nesting doll. Before dying, Merlin gives Balthazar his dragon figurine that will identify the Prime Merlinean, Merlin's descendant and the only one able to defeat Morgana. While searching for his descendant throughout history, Balthazar imprisons Morganians, sorcerers who try to release Morgana, including Horvath, into successive layers on the Grimhold.
Ten years later, Dave is a physics student at New York University. The ten-year imprisonment curse of the urn ends, releasing Horvath and Balthazar. Horvath pursues Dave and the Grimhold. Balthazar rescues Dave, riding an animated steel eagle adapted from a Chrysler Building gargoyle. Dave refuses to help Balthazar, having been under psychiatric care since their first meeting, until Balthazar agrees to leave after finding the Grimhold. They track the Grimhold to Chinatown, where Horvath has released the next Morganian, Sun Lok. Dave defeats Sun Lok, and Balthazar retrieves the Grimhold. Dave changes his mind and agrees to become Balthazar's apprentice. He also becomes romantically involved with his childhood crush, Becky, against Balthazar's wishes and advice.
Horvath enlists a youthful Morganian, celebrity magician Drake Stone, to get the Grimhold. They attempt to kill Dave, but Balthazar saves him. Cued by Horvath, Dave demands to know the truth about Balthazar's quest. Balthazar reveals that Morgana is trapped in the Grimhold with Veronica. Morgana, if freed, would cast a spell called "The Rising", which would revive sorcerers from the dead and enslave mankind. As Prime Merlinian, Dave is the only one who can stop her.