United States Air Force Brigadier General Jack D. Ripper (Sterling Hayden) is commander of Burpelson Air Force Base, which houses the Strategic Air Command 843rd Bomb Wing, equipped with B-52 bombers. The 843rd is currently in-flight on airborne alert, a few hours from the Soviet border.
General Ripper orders his executive officer, Group Captain Lionel Mandrake (Peter Sellers) of the UK Royal Air Force, to put the base on alert. Ripper also issues "Wing Attack Plan R" to the patrolling aircraft, one of which is commanded by Major T. J. "King" Kong (Slim Pickens). All of the aircraft commence an attack flight on Russia and set their radios to allow communications only through the CRM 114 discriminator, which is programmed to transmit 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 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 United States' water supplies to pollute the "precious bodily fluids" of Americans; at this point, Mandrake realizes that Ripper is insane.
At the Pentagon, General Buck Turgidson (George C. Scott) briefs President Merkin Muffley (also Peter Sellers) and other officers and aides about the attack in the "War Room". President Muffley is shocked to learn that such orders could be given without his authorization, but Turgidson reminds him that Plan R—enabling a senior officer to launch a strike against the Soviets if all superiors have been killed in a first strike on Washington D.C.—allows such an action. Turgidson reports that his men are trying every possible three-letter CRM code to issue the stand-down order, but that this could take over two days and the planes are due to reach their targets in about an hour. Muffley orders the Army chief to storm the base and arrest General Ripper.
Turgidson attempts to convince Muffley to let the attack continue and use the element of surprise to annihilate the Soviet military altogether before they can strike back; Muffley, however, refuses to be party to a nuclear first strike. Instead, he brings Soviet ambassador Alexei de Sadeski (Peter Bull) 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 planes' positions and targets so that the Russians 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 device, 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 cloud, wiping out all human and animal life, rendering the surface of the earth uninhabitable for 93 years. The device cannot be dismantled or "un-triggered", as it is programmed to explode if any such attempt is made. When the President's wheelchair-bound scientific advisor, former Nazi Dr. Strangelove (again, Peter Sellers), points out that such a doomsday device would only be an effective deterrent if everyone knew about it, de Sadeski replies that the Russian Premier had planned to reveal its existence to the world the following week.
Meanwhile, United States Army forces arrive at Burpelson, which is still sealed by General Ripper's order. A bloody battle ensues, and the Army forces eventually take over the base. Ripper kills himself, fearing he will be tortured into revealing the recall code. A soldier named Colonel "Bat" Guano (Keenan Wynn) forces his way into Ripper's office, where Mandrake identifies Ripper's CRM code from his desk blotter ("OPE," a variant of both Peace on Earth and Purity of Essence). Mandrake relays this code to the Pentagon with difficulty via payphone, the only working method of communication. Using the recall code, SAC successfully recalls most of the aircraft; however, Muffley learns that a surface-to-air missile has ruptured the fuel tank of Major Kong's plane and destroyed its communications device, making it impossible to recall this particular plane even with the correct recall code. President Muffley tells the Soviets the plane's target to help them find it, but doesn't realize that, because of the shortened range of the crippled aircraft, Major Kong has selected a closer target. When the plane approaches the new target, its damaged bomb doors fail to open at first. Major Kong adjusts the wiring, whereupon the doors open and the nuclear bomb falls with Kong straddling it, and detonates, triggering the doomsday machine.
Dr. Strangelove recommends that the President gather several hundred thousand people, with a high female-to-male ratio (10:1), to live in deep mineshafts where the radiation will not penetrate and then institute a breeding program to repopulate the Earth when the radiation has subsided. Turgidson warns that the Soviets will likely do the same and worries about a "mineshaft gap". The film then cuts to a montage of nuclear detonations, accompanied by Vera Lynn's recording of "We'll Meet Again".