In the 22nd century, rising sea levels from global warming have wiped out coastal cities, reducing the world’s population. Mecha, humanoid robots seemingly capable of complex thought but lacking in emotions, have been created. In Madison, New Jersey, David, a prototype Mecha child capable of experiencing love, is given to Henry Swinton and his wife Monica, whose son Martin contracted a rare disease and has been placed in suspended animation. Monica feels uneasy with David, but eventually warms to him and activates his imprinting protocol, causing him to have an enduring, childlike love for her. David seeks to have Monica express the same love towards him. He also befriends Teddy, Martin’s robotic teddy bear. Martin is unexpectedly cured of his disease and brought home. Martin becomes jealous of David, and taunts him to perform worrisome acts, such as cutting off locks of Monica’s hair while she is sleeping. At a pool party, one of Martin’s friends pokes David with a knife, triggering his self-protection programming. David grabs onto Martin, and they both fall into the pool. Martin is saved before he drowns, and Henry convinces Monica to return David to his creators to be destroyed. On the way there, Monica has a change of heart and spares David from destruction by leaving him in the woods. With Teddy as his only companion, David recalls The Adventures of Pinocchio and decides to find the Blue Fairy so that she may turn him into a real boy, which he believes will win back Monica’s love.
David and Teddy are captured by a Flesh Fair, where obsolete Mecha are destroyed before jeering crowds. David is nearly destroyed himself and pleads for his life. The audience, deceived by David’s realistic nature, revolts and allows David to escape alongside Gigolo Joe, a male prostitute Mecha on the run from authorities after being charged with murder. David, Teddy and Joe go to the decadent resort town of Rouge City, where “Dr. Know”, a holographic answer engine, directs them to the top of Rockefeller Center in the flooded ruins of Manhattan and has also provided fairy tale information interpreted by David as suggesting that a Blue Fairy has the power to help him. Above the ruins of Manhattan, David meets Professor Hobby, his creator, who tells him that their meeting demonstrates David’s ability to love and desire. David finds many copies of himself, including a female variant Darlene, boxed and ready to be shipped. Disheartened by his lost sense of individuality, David attempts suicide by falling from a skyscraper into the ocean. While underwater, David catches sight of a figure resembling the Blue Fairy before Joe rescues him in an amphibious aircraft. Before David can explain, Joe is captured via electromagnet by authorities. David and Teddy take control of the aircraft to see the Fairy, which turns out to be a statue from an attraction on Coney Island. The two become trapped when the Wonder Wheel falls on their vehicle. Believing the Blue Fairy to be real, David asks the statue to turn him into a real boy, and repeats this request until his internal power source is depleted.
Two thousand years later, humans are extinct and Manhattan is buried under glacial ice. The Mecha have evolved into an advanced form called Specialists, and have become interested in learning about humanity. They find and revive David and Teddy. David walks to the frozen Blue Fairy statue, which collapses when he touches it. The Specialists reconstruct the Swinton family home from David’s memories and explain to him, via an interactive image of the Blue Fairy, that it is impossible to make David a real boy. However, at David’s insistence, they recreate Monica through genetic material from the strand of hair that Teddy kept. This Monica can live for only one day, and the process cannot be repeated. David spends his happiest day with Monica, and as she falls asleep in the evening, she tells David that she has always loved him: “the everlasting moment he had been waiting for”, the narrator says; “David falls asleep as well and goes to that place ‘where dreams are born.'”