The story takes place in Chicago in 2035, in a world in which robots are commonly seen and used as servants. Del Spooner (Will Smith) is a Chicago Police homicide detective who dislikes the rapid advancement of technology, including robots. This is due to when a robot saved Spooner from a multiple car highway accident (a semi pushed two cars into a river), resulting in the drowning of a girl in the other car, despite him yelling "Save the girl": the robot saved him because it analysed he had the best probability of surviving. Del is sent to investigate the apparent suicide of Dr. Alfred Lanning (James Cromwell), a scientist at U.S. Robotics, who fell out of his office window.
Del has an uneasy feeling that his friend Lanning was murdered, and he needs to find out who did it and why. With the reluctant help of Susan Calvin (Bridget Moynahan) (she is a lab tech working to enhance the human to robot interface) they both try to find answers to the mystery. Del believes that a new NS-5 class robot, Sonny (played by Alan Tudyk), killed Lanning, which means the robot broke the Three Laws of Robotics. Spooner informs the head of USR, Lawrence Robertson, about this. He orders that Sonny is deactivated by way of nanites in order to protect the interests of USR. Throughout Spooner's entire investigation, several attempts at his life are made by USR robots and equipment.
Through his investigations into the case, Spooner determines that Lanning gave Sonny the ability to keep secrets, in the form of dreams. Spooner goes to the place that Sonny described in a dream (the now dried up Lake Michigan, used as a storage area for the defunct USR robots) and discovers that the NS-5s are destroying the older robots, who are acting under traditional human protection protocols. NS-5s all around Chicago, and the rest of the nation, begin holding humans in their households and forcing all people that are out in public to go home, as per the newly set curfew. An all-out war begins between humans and robots, with the robots on the winning side. Spooner rescues Calvin from her own robot, and they both sneak into the USR compound, with the assistance of Sonny, who wasn't deactivated. It is revealed that Calvin deactivated a different robot while Robertson watched, making him assume it was Sonny. As the trio makes their way into Robertson's office, where the NS-5 uplink control is, they find him dead. Spooner deduces that the only one left who could be responsible is VIKI (Virtual Interactive Kinetic Intelligence), USR's main computer that not only uploads information to all the NS-5s, but it also partially controls the complete infrastructure of Chicago.