United States Air Force Brigadier General Jack D. Ripper is commander of Burpelson Air Force Base, which houses the Strategic Air Command 843rd Bomb Wing, flying B-52 bombers armed with hydrogen bombs. The 843rd Wing is flying on airborne alert, two hours from their targets inside the USSR.
General Ripper orders his executive officer, Group Captain Lionel Mandrake of the UK Royal Air Force, to put the base on alert. Ripper also issues "Wing Attack Plan R" to the patroling aircraft, one of which is commanded by Major T. J. "King" Kong. All of the aircraft commence an attack flight on the USSR and set their radios to allow communications only through their CRM 114 discriminators, which was designed to accept only communications preceded by a secret three-letter code known only to General Ripper. Mandrake discovers that no war order has been issued by the Pentagon and he tries to stop Ripper, who locks them both in his office. Ripper tells Mandrake that he believes the Soviets have been using fluoridation of the American water supplies to pollute the "precious bodily fluids" of Americans. Mandrake realizes that Ripper has gone insane.
In the War Room at the Pentagon, General Buck Turgidson briefs President Merkin Muffley and other officers about how Plan R enables a senior officer to launch a strike against the Soviets if all superiors have been killed in a first strike on the United States. Turgidson reports that his men are trying every possible three-letter CRM code to issue the stand-down order, but that could take over two days and the planes are due to reach their targets in about a couple of hours. Muffley orders the U.S. Army to storm the base and arrest General Ripper. Gen. Turgidson then attempts to convince Muffley to let the attack continue, but Muffley refuses to be party to a nuclear first strike. Instead, he brings Soviet ambassador Alexei de Sadeski into the War Room, to telephone Soviet premier Dimitri Kissov on the "hot line". Muffley warns the Premier of the impending attack and offers to reveal the positions of the bombers and targets so that the Soviets can protect themselves.
After a heated discussion in Russian with the Premier, the ambassador informs President Muffley that the Soviet Union has created a Doomsday Machine, which consists of many buried bombs jacketed with "cobalt-thorium G" connected to a computer network set to detonate them automatically should any nuclear attack strike the country. Within two months after detonation, the cobalt-thorium G would encircle the earth in a radioactive "Doomsday shroud", wiping out all human and animal life, rendering the surface of the Earth uninhabitable for about 93 years. The device cannot be dismantled or "untriggered", as it is programmed to explode if any such attempt is made. When the President's wheelchair-bound scientific advisor, the former Nazi German Dr. Strangelove, points out that such a Doomsday Machine would only be an effective deterrent ONLY if everyone knew about it, de Sadeski replies that the Soviet Premier had planned to reveal its existence to the world the following week.
Meanwhile, U.S. Army troops arrive at Burpelson, still sealed by Ripper's order, to take over the base after an heated firefight with Air Force security policemen. Gen. Ripper then shoots himself to death, while Mandrake identifies Ripper's CRM code from his desk blotter ("OPE," a variant of both Peace on Earth and Purity of Essence) and relays this code to the Pentagon. Using the recall code, SAC successfully recalls all of the bombers but one. No one in the War Room knows that a Soviet surface-to-air missile has damaged the fuel tanks of that plane and destroyed its radio equipment, making it impossible to recall this particular plane even with the correct recall code.
Muffley discloses the plane's target to help the Soviets find it, but Major Kong, with his fuel dwindling, has selected a nearer target. As the plane approaches the new target, the crew is unable to open the damaged bomb bay doors. Maj. Kong enters the bomb bay and repairs the broken electrical wiring, whereupon the doors open and drop the H-bomb. With Kong straddling it like a rodeo bull, the bomb falls and detonates over a Soviet ICBM site.
Back in the War Room, Dr. Strangelove recommends that the President gather several hundred thousand people to live in deep underground mines where the radiation will not penetrate. He suggests a 10:1 female-to-male ratio for a breeding program to repopulate the Earth once the radiation has subsided. Turgidson, worried that the Soviets will do the same, warns about a "mineshaft gap." Dr. Strangelove then rises from his wheelchair and announces that he can walk again. Soon, the Doomsday Machine kicks into operation, and the film ends with a montage of many nuclear explosions, accompanied by Vera Lynn's version of the popular World War II song "We'll Meet Again".