James Bond—Agent 007—is assigned to aid the defection of a KGB officer, General Georgi Koskov, covering his escape from a concert hall in Bratislava, Czechoslovakia during the orchestra's intermission. During the mission, Bond notices that the KGB sniper assigned to prevent Koskov's escape is a female cellist from the orchestra. Disobeying his orders to kill the sniper, he instead shoots the rifle from her hands, then uses the Trans-Siberian Pipeline to smuggle Koskov across the border into Austria and then on to Britain.
In his post-defection debriefing, Koskov informs MI6 that the KGB's old policy of Smiert Spionom, meaning Death to Spies, has been revived by General Leonid Pushkin, the new head of the KGB. Koskov is later abducted from the safe-house and assumed to have been taken back to Moscow. Bond is directed to track down Pushkin in Tangier and kill him in order to forestall further killings of agents and escalation of tensions between the Soviet Union and the West. Although Bond's prior knowledge of Pushkin initially leads him to doubt Koskov's claims, he agrees to carry out the mission when he learns that the assassin who killed 004 (as depicted in the pre-title sequence) left a note bearing the same message, "Smiert Spionom."
Bond returns to Bratislava to track down the cellist, Kara Milovy. He determines that Koskov's entire defection was staged, and that Milovy is actually Koskov's girlfriend. Bond convinces Milovy that he is a friend of Koskov's and persuades her to accompany him to Vienna, supposedly to be reunited with him. Meanwhile, Pushkin meets with arms dealer Brad Whitaker in Tangier, informing him that the KGB is cancelling an arms deal previously arranged between Koskov and Whitaker.
During his brief tryst with Milovy in Vienna, Bond meets his MI6 ally, Saunders, who discovers a history of financial dealings between Koskov and Whitaker. As he leaves their meeting, Saunders is killed by Necros (Koskov and Whitaker's henchman), who again leaves the message "Smiert Spionom."
Bond and Milovy promptly leave for Tangier, where Bond confronts Pushkin. Pushkin disavows any knowledge of "Smiert Spionom", and reveals that Koskov is evading arrest for embezzlement of government funds. Bond and Pushkin then join forces and Bond fakes Pushkin's assassination, inducing Whitaker and Koskov to progress with their scheme. Meanwhile, Milovy contacts Koskov, who tells her that Bond is actually a KGB agent and convinces her to drug him so he can be captured.
Koskov, Necros, Milovy, and the captive Bond fly to a Soviet air base in Afghanistan—part of the Soviet war in Afghanistan—where Koskov betrays Milovy and imprisons her along with Bond. The pair escape and in doing so free a condemned prisoner, Kamran Shah, leader of the local Mujahideen. Bond and Milovy discover that Koskov is using Soviet funds to buy a massive shipment of opium from the Mujahideen, intending to keep the profits with enough left over to supply the Soviets with their arms.
With the Mujahideen's help, Bond plants a bomb aboard the cargo plane carrying the opium, but is spotted and has no choice but to barricade himself in the plane. Meanwhile the Mujahideen attack the air base on horseback and engage the Soviets in a gun battle. During the battle, Milovy drives a jeep into the back of the plane as Bond takes off, and Necros also leaps aboard at the last second. After a struggle, Bond throws Necros to his death and deactivates the bomb. Bond then notices Shah and his men being pursued by Soviet forces. He re-activates the bomb and drops it out of the plane and onto a bridge, blowing it up and helping Shah and his men gain an important victory over the Soviets. Bond returns to Tangier to kill Whitaker, as Pushkin arrests Koskov, sending him back to Moscow.
Some time later, Milovy is the lead cellist in a known London performance, her music career solidified by newfound cooperation between the British government and the Soviets providing Kara with travel expenses and allowing her to perform in both countries. After her performance, Bond surprises her in her dressing room and they romantically share their mutual success together.