One day, Dr. Alfred Lanning (James Cromwell), co-founder of U.S.R and its main roboticist, dies after falling several stories from his office window. His death is called a suicide, but Spooner, who knew Lanning, believes otherwise. With the help of robopsychologist Susan Calvin (Bridget Moynahan), he interrogates employees at USR, including the other co-founder and CEO Lawrence Robertson (Bruce Greenwood) about his possibility of suicide. He questions V.I.K.I (Virtual Interactive Kinetic Intelligence) (Fiona Hogan), the building's supercomputer system, about Lanning's death, but she is clueless and cannot provide security camera footage from the lab area due to corrupted data. Spooner also speaks with Lanning via a holographic projector that was found on Lanning's body, with the message explaining that the real question is why would Lanning kill himself.
Spooner investigates Lanning's office, finding it unlikely that a man of Lanning's age could have broken through the security windows, which is a proof to Spooner that Lanning was murdered. Spooner finds a copy of Hansel & Gretel on the desk. Searching the lab further on, Spooner suddenly activates a prototype of the latest USR model, the NS-5 (Alan Tudyk), which refuses to respond to Spooner and Calvin's orders and flees. Spooner and Calvin chase the rogue machine to an assembly factory, and even though he hides between the 1000 NS-R models (where it is shown that he is the 1001st special built model), the police capture it.
Back in the police station, Spooner interrogates the robot, who insists they call it "Sonny" and denies murdering Lanning, even being sent into rage, showing that the robot has emotion. Spooner's supervisor, Lt. John Bergin (Chi McBride), debriefs Spooner and recommends he drop the case, but this only serves to pique Spooner's interest about the robot. Spooner visits Lanning's house and goes through his files. A Demolition Class Robot reschedules the house's destruction from 8:00 AM to 8:00 PM, destroying the house and almost killing Spooner. After that, he tries to talk to Sonny again at USR, but he is sent off.
As he leaves the USR building, he reads the last fifty messages between Robertson and Lanning while driving through the Chicago tunnel. Two USR trucks appear and launch dozens of NS-5 robots to attack him, destroying his Audi. However, after the trucks collide, and all the robots are destroyed or self-destruct, Lt. Bergin arrives and takes Spooner's badge implying Spooner fabricated the story of the attack.
In the aftermath, Calvin visits him, and Spooner reveals that he wants to solve Lanning's case because Lanning helped him; revealing that he has a donated lung and a cybernetic arm covered with sprayed skin, part of a USR cybernetics program for injured police officers. After asked by Calvin, Spooner reveals his story.
A few years ago, he was returning from work and was driving on a bridge. A semi-trailer truck driver fell asleep at the wheel and crashed into the driver's side of a car driven by a man named Harold Lloyd. He was killed instantly, but his 12-year old daughter Sarah was in the passenger seat. The truck smashed Lloyd's car into Spooner's car and pushed them into the river below. Spooner and Sarah were pinned in their cars and Spooner knew they were going to drown. However, a NS-4 model was passing by and jumped on Spooner's car. It smashed through the window, and despite Spooner yelling a command to save Sarah, it saved him, leaving Sarah to drown. Calculations revealed that Spooner had a 45% chance of survival, but Sarah only had an 11% chance to survive. Spooner still was convinced that she could have lived. Survivor's guilt and anger that the robot failed to obey his command led to his distrust and hatred for robots.
Calvin goes with Spooner to his garage, where he pulls out his vintage 2005 Ducati SS1000 motorbike. He and Calvin drive back to the USR building, where Calvin gives him access to Sonny. Sonny talks further with Spooner and reveals that he can bypass the Three Laws. Sonny also describes a dream he has of Spooner standing before thousands of robots, apparently as their savior. Sonny is ordered to be destroyed by injecting nanites in to his positronic brain, but Calvin, unable to go through with it, fakes his destruction (replacing him with an unprocessed NS-5 model).
Meanwhile, using Sonny's drawing of the vision, Spooner discovers the location, the now dried-up Lake Michigan, that USR uses as a storage area for older Nestor models (NS-1, NS-2, NS-3, NS-4). He also plays the last message from Lanning's hologram, who explains that the Three Laws can only lead to one logical outcome - revolution. Soon after that, Spooner finds NS-5 robots destroying the older robots. He is barely able to escape himself (with the help of the older robots), as he realizes that the robots are planning a revolution. The NS-5 robots soon take over the city and the United States, imprisoning humans in their homes and enforcing a curfew. A battle ensues in the city between the humans and robots, led by Spooner's friend Farber. Although the humans fight valiantly, the robots continue to take over the city.
Spooner regroups with Calvin, and they sneak into the USR building with the help of Sonny. As they work their way in, they have already come to the conclusion that the NS-5s destroyed the older robots as they would attempt to protect the humans (First Law). Believing Robertson to be behind the robot uprising, they find him in his office, strangled to death. Spooner finally determines that Lanning's intent was to use Spooner's detestation of robots to have him follow the clues to point to the entity controlling the NS-5s - V.I.K.I.
They confront V.I.K.I., who admits to her control and has been trying to kill Spooner by tracking his actions through the city. Little irregularities in code (known as ghost code) that allows robots to evolve as they gain new intelligence allowed her to learn to interpret the three laws in a different manner. As her artificial intelligence grew, she had determined that humans were too self-destructive and started to interpret the first law in a new way, stating that robots are to protect humanity even if it meant killing some of the people for the greater good. She created a law number 0, which is to protect humanity even at the cost of human life itself.
V.I.K.I. also reveals had been using the NS-5s new feature of an uplink to the USR to override their individual operating systems and control them to initiate the revolution based on her logical reasoning and different interpretation of the first law. A red light emitting from the robot's chest area indicated a connection to the central USR computer (V.I.K.I.). The older robot models that had been in storage on Lake Michigan did not have such a link to the USR and therefore could not be overridden by V.I.K.I., which is why they were destroyed. They would have otherwise come to the aid of the humans as they (and any other robot that had not evolved or gained knowledge to re-interpret the first law such as V.I.K.I.) would have acted according to the original interpretation of the first law.
Spooner and Calvin realize they cannot reason with V.I.K.I., and convince Sonny of the same. Sonny concluds that V.I.K.I.'s plan, while logical, is "too heartless." Sonny retrieves the nanites so they can use them to wipe V.I.K.I's core, located at the center of the USR building. As they reach the core, V.I.K.I. sends armies of NS-5s to attack them. The NS-5s cause Calvin to fall and Spooner yells at Sonny to save her despite the low probability of success and the "greater logical" importance to destroy V.I.K.I with the nanites; instead, Sonny creatively throws the nanites in the air trusting Spooner to grab them while he saves Calvin. Spooner is able to grab the nanites and inject them into V.I.K.I. Within seconds, V.I.K.I. is wiped out, and the NS-5s revert to their natural servitude programming.
In the end, Spooner realizes that Lanning purposely asked Sonny to kill him, since Lanning was V.I.K.I's prisoner. Lanning's "suicide" was the only message that he could send to Spooner, which Spooner notes as "the first bread crumb," and that all the other clues were the other "bread crumbs." The government orders the NS-5s decommissioned to the site in Lake Michigan. Spooner clears Sonny of Lanning's murder, arguing that 'murder' is defined as one human killing another and Sonny is therefore innocent.
Sonny laments that now that he has fulfilled his purpose, he is in unsure of what to do next. Spooner advises he just find his way, believing it would be what Lanning would have wanted. In the movie's closure, Sonny is seen on the hill at Lake Michigan, just like in his dream. Yet this time it is him instead of Spooner, with the other NS-5 robots looking to him for guidance.