Bashir is enjoying a holosuite program that casts him as a super suave, 1960s Earth secret agent when Garak intrudes on his fantasy, convincing the doctor to let him stay. At the same time, Sisko, Kira, Dax, Worf, and O'Brien transport from a Runabout just before sabotage causes it to explode, but the force of the blast blows out the Transporter during Eddington's rescue attempt. He is able to store their patterns with an emergency computer override — but where?

Kira suddenly appears in Bashir's program as Anastasia, a Russian spy — and is completely oblivious to her true identity as Kira. Concerned, Bashir contacts Ops, and Eddington tells him about the accident. Realizing this is where the physical patterns of the officers are now stored, he tells Bashir to keep the program going, since ending it could end his crewmates' lives. Playing along, Bashir asks Kira to explain their assignment, and she tells him about a string of artificial earthquakes and the disappearance of Professor Honey Bare, whose photograph looks just like Dax. Bashir and Garak are even more surprised, however, when O'Brien appears as Falcon, the program's hired assassin, and pulls a gun on them.

The three overpower O'Brien and his two henchmen, then Kira prepares to kill him. But Bashir stops her, realizing that she would be killing the real O'Brien's body instead of a program. Traveling to Paris, Bashir poses as a noted scientist, believing a Dr. Noah may be behind the disappearance of Professor Bare. Bashir, Garak, and Kira meet up with Worf, who is now Duchamps, Dr. Noah's assistant. He knocks the three unconscious, and they wind up at Dr. Noah's headquarters on the slope of Mt. Everest. There, they meet Noah, who is actually Sisko.

Sisko explains his diabolical plan to destroy the planet by creating artificial quakes that will release lava from the Earth's core. As it shrinks, oceans will flood everything but Mt. Everest, where Noah will start a new society there on his "island." The scientist helping Noah is Professor Bare/Dax, who appears to be assisting voluntarily. After explaining his plan, Sisko reveals that O'Brien is also working for him, and that he knows Bashir is really a secret agent. They then take Bashir and Garak to a cave, where they are handcuffed to a laser which in five minutes will drill a hole into the ground, releasing a pool of lava into the cave and killing them.

Luckily, Dax lets her attraction to Bashir get the better of her and rescues him just in time. Garak then tries to end the program, but Bashir shoots him, proving he is serious. They return to the control room, where Bashir pretends to want to join Sisko's side, then actually deploys his deadly device and destroys the world. Unsure what to do, Sisko prepares to shoot Bashir anyway, but suddenly dematerializes along with the rest of the trapped physical patterns, which are finally reunited with their neural patterns on the Defiant's transporter pad. Only Garak and Bashir remain in the program. Like true secret agents, they actually saved the day.