Michael Jackson’s “Bad,” blasted near the end of “Megamind,” the witty 3-D animated deconstruction of superhero movies from DreamWorks Animation, encapsulates the paradoxes of a story in which evil morphs into good and vice versa. There was always something innately silly in Jackson’s wispy-voiced, childlike affectation of macho ferocity. My first reaction to a singer whose clout suggested a crooked finger more than a clenched fist was, “Oh, come off it, little boy.”

And so it is with Megamind, the movie’s blue-faced, green-eyed, eggheaded title character, whose grandiose evil schemes usually come to naught and who loses every battle with his not entirely virtuous nemesis, Metro Man. Voiced by Will Ferrell, Megamind is a hyper-sensitive brainiac who sounds a little like Stewie Griffin, the weirdly effete child played by Seth MacFarlane in “Family Guy” (whose British accent is said to have been inspired by Rex Harrison). More Conehead than cave man, Megamind, whose lair is an abandoned power plant cluttered with machinery, is a comic antihero for the age of the geek.

Metro Man (the voice of Brad Pitt) is equally ambiguous. A smug, grinning Superman with a wavy Elvis haircut, he wallows in self-satisfaction as the residents of Metro City heap glory on him. His jaw is a little too prominent, his body a little too pumped, his attitude a little too cocky for him to be trusted as an unassailable moral paragon. He isn’t really a hero; he’s just a star.

When at a certain point in the movie Metro Man is accidentally vanquished and is presumed dead, Megamind faces an existential crisis. Without an opponent he has no purpose in life. The movie’s central joke — that good and evil are meaningless unless both exist in continual opposition — is unusually sophisticated for an animated movie. And the screenplay by Alan Schoolcraft and Brent Simons plays that insight every which way.

Disconsolate, bored and at loose ends, Megamind decides he must create a Metro Man replacement. Wielding his considerable but imperfect magic, he transforms Hal (Jonah Hill), the nerdy redheaded cameraman for the local television station and the movie’s answer to Jimmy Olsen, into the super-powered Tighten (also Mr. Hill). But Tighten, an angry postadolescent outcast nursing many grudges, quickly discovers that wreaking vengeance against a world that looked down on him is much more fun than doing good, and he runs amok.

True to its title, “Megamind,” directed by Tom McGrath (both “Madagascar” movies), has a lot more in its head than the typical aspiring animated blockbuster, including the more user-friendly “Shrek” movies. Nurture versus nature is one theme. Both Megamind and Metro Man were conceived on a dying planet and simultaneously sent to Earth. Megamind lands in a Metro City prison, where he learns evil, while Metro Man is coddled in upper-middle-class comfort.

To borrow a concept from psychotherapy, the essential selves of Megamind and Metro Man are neither all good nor all bad. The film has a lot riding on how much ambiguity audiences accustomed to more clear-cut personifications of good and evil can tolerate.

It also addresses the limitations of technology. Megamind’s elaborate schemes may be great on paper, but their execution disappoints; he doesn’t reckon on the time it takes to upload a computer-generated program of mass destruction. You could apply the same lesson to pinpoint bombing by remote control.

For mild comic distraction in a movie that is skimpier than most in generating laughter, there is Minion (David Cross), Megamind’s loyal assistant, who has a fishbowl head, the body of a robot gorilla and a fanged underbite. The voice of common sense in Megamind’s mentally overstimulated world, the character isn’t as a sharp or as funny as he could be.

The movie’s Lois Lane is Roxanne Ritchi (Tina Fey), a beautiful and fearless television news reporter coveted by Megamind, Metro Man and Tighten alike. She is no pushover. When the preening, flexing Tighten tries to wow her by repeatedly dropping her from on high, then swooping down to scoop her up at the last second, she is irritated by his showy stunts.

Typical of DreamWorks Animation toons, “Megamind” is crammed with pop culture references and jokes invented to show how up-to-the-minute it is in its slang and encyclopedic comic-book know-how. Megamind is a master of disguises who in his funniest incarnation becomes a parody of Marlon Brando in “Superman.” Fragments of vintage hits include AC/DC’s “Highway to Hell” (symbolizing evil) and Minnie Riperton’s chirpy “Lovin’ You,” (good). These references are just the outer layer of a compulsively referential screenplay that tries so hard, it sounds like a classroom smart aleck reeling off answers before the questions are finished.

Visually “Megamind” is immaculately sleek and gracefully enhanced by 3-D. The score by Hans Zimmer and Lorne Balfe is refreshingly subtle for an action comedy. The opposite of the dark, murky Gotham City of “Batman,” Metro City is a gleaming hub of institutional architecture, spacious promenades and jutting spires.

Directed by Tom McGrath; written by Alan Schoolcraft and Brent Simons; edited by Michael Andrews; music by Hans Zimmer and Lorne Balfe; production design by David James; produced by Denise Nolan Cascino and Lara Breay; released by DreamWorks Animation and Paramount Pictures. Running time: 1 hour 36 minutes.

A film review on Friday about the animated feature “Megamind” misidentified the character who tries to impress Roxanne by repeatedly dropping her from high in the air then swooping down to rescue her. He is Tighten, not Metro Man.

A version of this review appears in print on November 5, 2010, on page C15 of the New York edition with the headline: Animated Ambiguity, Featuring A Big Head. Order Reprints|Today's Paper|Subscribe