During a surprise drill of a nuclear attack, many United States Air Force Strategic Missile Wing missileers prove unwilling to turn a required key to launch a missile strike. Such refusals convince John McKittrick (Dabney Coleman) and other systems engineers at NORAD that missile launch control centers must be automated, without human intervention. Control is given to a NORAD supercomputer, WOPR (War Operation Plan Response), programmed to continuously run military simulations and learn over time.
David Lightman (Matthew Broderick) is a bright but unmotivated Seattle high school student and hacker. After receiving a failing grade in school, he uses his IMSAI 8080 microcomputer to hack into the district's computer system. He then changes his grade and does the same for his friend and classmate Jennifer Mack (Ally Sheedy). Later, while dialing every number in Sunnyvale, California to find a set of forthcoming computer games, a computer that does not identify itself intrigues David. On the computer he finds a list of games, starting with general strategy games like chess, checkers, backgammon, and poker and then progressing to titles like "Theaterwide Biotoxic and Chemical Warfare" and "Global Thermonuclear War", but cannot proceed further. Two hacker friends explain the concept of a backdoor password and suggest tracking down the Falken referenced in "Falken's Maze", the first game listed. David discovers that Stephen Falken is an early artificial intelligence researcher, and guesses correctly that his dead son's name "Joshua" is the backdoor password.
David does not know that the Sunnyvale phone number connects to WOPR, or "Joshua", at Cheyenne Mountain Complex. He starts a game of Global Thermonuclear War, playing as the Soviet Union. The computer starts a simulation that briefly convinces the military personnel at NORAD that actual Soviet nuclear missiles are inbound. While they defuse the situation, Joshua nonetheless continues the simulation to trigger the scenario and win the game, as it does not understand the difference between reality and simulation. It continuously feeds false data such as Soviet bomber incursions and submarine deployments to the humans at NORAD, pushing them into raising the DEFCON level and toward a retaliation that will start World War III.
David learns the true nature of his actions from a news broadcast, and the FBI arrests him and takes him to NORAD. He realizes that Joshua is behind the NORAD alerts but because he fails to convince McKittrick about this, he faces imprisonment. David escapes NORAD by joining a tourist group and, with Jennifer's help, travels to the Oregon island where Falken (John Wood) now lives. David and Jennifer find that Falken has become despondent and believes that nuclear war is inevitable, that it is as futile as a game of tic-tac-toe between two experienced players. The teenagers convince Falken that he should return to NORAD to stop Joshua.
The computer stages a massive Soviet first strike with hundreds of missiles, submarines, and bombers. Believing the attack to be genuine, NORAD prepares to retaliate. Falken, David, and Jennifer convince military officials to cancel the second strike and ride out the non-existent attack. Joshua tries to launch the missiles itself, however, using a brute force attack to obtain the launch code. Without humans in the control centers as a safeguard, the computer will trigger a mass launch. All attempts to log in and order Joshua to cancel the countdown fail, and all weapons will launch if the computer is disabled.
Falken and David direct the computer to play tic-tac-toe against itself. This results in a long string of draws, forcing the computer to learn the concept of futility and no-win scenarios. Joshua obtains the missile code but before launching, it cycles through all the nuclear war scenarios it has devised, finding they too all result in stalemates. Having discovered the concept of Mutually Assured Destruction ("WINNER: NONE"), the computer tells Falken that it has concluded that nuclear war is "a strange game" in which "the only winning move is not to play." Joshua relinquishes control of NORAD and the missiles and offers to play "a nice game of chess."
Who convinces the military officials to cancel the second strike?
Falken, David, and Jennifer