The pre-title teaser takes place in an unidentified Latin American country: James Bond infiltrates a military airbase in order to plant a bomb on a secret radar system, however he is quickly captured by the same officer that he impersonates. As his captors drive him off the base, Bond's female assistant distracts the guards enough for the agent to escape. Using an Acrostar mini-jet, Bond attempts to fly out of the country. A missile is launched from a nearby battery and streaks towards his plane. Bond is unable to outmaneuver the missile at first but is able to lure it into the aircraft hangar where he'd previously failed to destroy the radar system: he flies straight through it, trapping the missile inside and destroying the hangar. As he streaks away, Bond sees that he is nearly out of fuel. He lands near a gas station and asks the attendant to "Fill her up, please."
In Eastern Germany a clown is fleeing a circus, with two knife-throwing twins in pursuit. As he tries to escape at a boarder crossing into West Germany, one of the twins hits him with a throwing knife and he falls into a river and is washed away. The man survives the attack and stumbles into the British embassy. He crashes through a glass door and falls dead, a jeweled egg rolling from his hand. In London, Bond reports to his MI6 superior, M, who tells him about the recovered egg which was made by Carl Faberge for the Russian royal family. M informs Bond that the egg is a very elaborately constructed fake and that the real egg is up for auction. Bond attends the auction with MI6s antiquities expert and, during the tense bidding for the egg where Bond himself drives up the price, switches the fake for the authentic one. The bidder who wins the egg is a wealthy Afghani exile named Kamal Khan. Bond follows him to Delhi in India.
Bond goes to his hotel's nightclub to meet Khan socially. Khan seems unbeatable in backgammon until Bond steps up and wagers the authentic egg. Bond exposes Khan's method of cheating; he uses loaded dice, which Bond seizes and uses to his own advantage, winning a large sum of money in the bargain. As he reports to MI6s safe house, he is attacked by Khan's henchmen, one of them is his personal bodyguard, the turbaned giant, Gobinda. Bond evades his pursuers and finds himself in Q's lab. Q plants a tracking device on the egg and synchs it to Bond's wristwatch.
Later, at his hotel, Bond meets another of Khan's operatives, a beautiful woman named Magda, who tells Bond he may trade the egg for his life. Bond sleeps with her, knowing she'll steal the egg. While they're in bed, Bond notices she has an elaborate tattoo of a blue-ringed octopus. Magda escapes Bond's room and is picked up by Khan. Gobinda appears and hits Bond, rendering him unconscious.
Bond awakes in Khan's palace and Gobinda informs him that he will attend dinner at 8pm. At the meal, Bond asks why he's being held captive when Khan has the egg. Khan intends to torture Bond to find out what he knows. Following dinner, Bond escapes his room and makes his way to the lower chambers of the palace where he finds Khan meeting with a Russian general, Orlov, however, the details about the egg are still unclear. Orlov orders Khan to kill Bond. When Khan finds out that Bond has escaped his confinement, Khan orders a hunting party formed. Bond is able to evade them and the dangers of the nearby jungle.
Bond reports to Q who supplies him with a motorized fake alligator which allows him to infiltrate the mysterious floating palace, inhabited only by beautiful women and their secretive leader. He finds a woman, Octopussy, who leads the Octopus Cult, women who are assassins and thieves, who pose as circus performers. She and Bond actually share a connection; her father was a thief whom Bond had tracked years before, however, before Bond could arrest the man, he killed himself and the gold the man had looted was never found. Khan himself suddenly appears, saying that Bond had escaped, however, Octopussy tells Khan that the agent is staying with her. Khan leaves, silently furious at the turn of events.
Bond snoops around Octopussy's private study and finds a flyer for her circus. She walks in the room and tells Bond she'll be going away for a week. During their meeting, while Bond was spying on them, Orlov had spoken of a German city, Karl-Marx-Stadt. Bond suspects that Octopussy will be going there with Khan. He and Octopussy quarrel a bit when Bond says he may not be there when she returns. The two make love; while in bed together they are attacked by assassins after Bond. Bond and Octopussy thwart them all, however Bond is forced out a window and into the river. He appears to be eaten by an alligator, however it is the same false one he used to infiltrate the palace. Returning to the stakeout point where Q and Bond's Indian contact, Vijay, had been waiting for him, Bond finds Q with the murdered Vijay. Before he died, Vijay confided in Q that he was attacked by Kamal's men. Bond tells Q to contact M and inform him that he needs to travel to Karl-Marx-Stadt.
Bond travels to Eastern Germany and secretly attends Octopussy's circus. Posing as a circus employee, Bond discovers that the Faberge egg is part of a cache of priceless jewelry being used to pay Orlov for a stolen Soviet nuclear bomb that will be detonated on the American airbase at Feldstadt in Western Germany. The nuclear explosion will be planned to look like an accident by the United States - the bomb will be housed in the cannon from the human cannonball stunt in the show, which will also make smuggling it over the East/West German border easier. Orlov hopes that NATO will order nuclear disarmament throughout Europe so that he may make a lightning armored strike through the Iron Curtain and take over. The fake jewelry has already been delivered by Orlov to the Moscow Ministry of Antiquities to take the place of the stolen items. Orlov's superior, General Gogol, having discovered that the jewelry in Moscow is bogus, immediately departs for the East-West German border to apprehend Orlov.
Bond is able to find the train car with the cannon where the jewelry is also hidden for smuggling purposes. The jewelry is being removed from one cannon and being placed into another - Khan and Orlov have been working together to double-cross Octopussy from the beginning. Bond finds one of the twin knife-throwers making the switch and kills him, hiding the body in the cannon's barrel and donning his clothes. Bond interrogates Orlov when the latter arrives to inspect the work, finding out his plan for conquering Europe. Bond is forced to retreat when Soviet guards come to aid Orlov and he steals Orlov's car. During a brief chase, the tires on Orlov's car are shredded and Bond drives onto the train tracks in pursuit of the train itself. He manages to board the train with Orlov in pursuit. He also hides in the cannon car and witnesses Khan and Gobinda arming the bomb. Gobinda hears a clang in the room caused by Bond while hiding in a gorilla suit. He follows Bond to the roof of the train where they battle briefly. The brother of the twin that Bond killed finds them both but realizes that Bond is not his brother. The two fall off the train together, Bond being pursued by the twin - Bond kills the man and now finds himself lagging behind the train. He hitches a ride with a German couple, then steals a woman's car and drives to the airbase at Feldstadt with the police in pursuit.
Bond trades the twin's clothing for a clown suit and goes in search of the cannon. Bond immediately runs to the base commander, who is sitting with Octopussy at the performance. Khan had already stolen out of the tent to clear the blast area, leaving Octopussy behind. Bond tells the commander that the bomb is about to go off and pleads with Octopussy to back him up. Failing that, Bond returns to the cannon to open the box and disarm the bomb. When the box is opened and the bomb exposed, the base commander gives Bond time to disarm the bomb, which he does.
Both Bond and Octopussy separately follow Khan to his palace in Delhi. Octopussy uses her women followers as commandos to infiltrate the palace and subdue Khan's men. Octopussy finds Khan herself but is captured. Khan retreats to a waiting plane and takes off. Bond manages to grab hold of the plane's exterior and refuses to be thrown off by Khan. Khan sends Gobinda out to deal with Bond but Bond is able to throw him off the craft. Bond next disables the tail mechanisms, sending the plan plummeting towards earth. Bond is able to find Octopussy inside the plane and the two jump to safety just before the plane crashes into a cliff, killing Khan.
Back in London, M meets with Gogol, who wishes to congratulate Bond personally for stopping Orlov. M says that Bond is still in India, recovering from varying injuries. In truth, Bond is fine and spends a romantic evening with Octopussy aboard her yacht.