In the wake of the peace treaty with Cardassia, Sisko is excited about working with two Cardassian scientists who are assigned to help deploy a subspace relay in the Gamma Quadrant — a project which, if successful, will allow communication through the wormhole for the first time. But Vedek Yarka warns that an old Bajoran prophecy predicts destruction of the wormhole, as three "vipers" will return to their "nest" in the sky. He deduces that the scientists are the vipers and the station must be their nest. Still, there are only two Cardassians arriving, and Sisko believes the project is too important to abandon. Later, the Cardassian scientists, Ulani and Gilora, arrive, and immediately put the crew at ease with their friendly manner. However, when they announce that another scientist will soon be joining them, Kira is concerned, believing this is the third "viper" in the prophecy.

Yarka begs Kira to have Sisko send away the Cardassians, but she will not let her faith interfere with her duties. After Dejar, the third scientist, arrives at the station, Gilora and O'Brien prepare to receive the signal from the Gamma Quadrant, while Dejar and Ulani travel there with Sisko, Kira, and Dax on the Defiant in order to set up the relay. As soon as they arrive, the crew encounters a large rogue comet, which Kira sees as the "sword of stars" mentioned in the prophecy.

Kira tells Sisko she believes the prophecy is coming true, and that Sisko, as the Emissary of Bajoran lore, must make a decision just as it foretells. Sisko, however, has always been unwilling to accept that he actually is the Emissary. He then has Dax send the first transmission through the wormhole, but it fails. The modified signal instead triggers the wormhole to open violently and experience a brief, drastic increase in gravity, which alters the comet's course, causing it to head directly for the anomaly. If the comet enters it, the material in the core will make the wormhole collapse permanently — which is apparently part of the prophecy.

Back at the station, O'Brien and Gilora modify the Defiant's phasers in order to vaporize the entire comet at once. But when the ship returns to the Gamma Quadrant to implement the plan, the weapons relay malfunctions, causing the phasers to instead fire a standard burst, which splits the comet into three fragments — all of which remain on course for the wormhole.

Gilora reveals that Dejar, who is a member of the Obsidian Order, sabotaged the phasers. Once Dejar is detained, Sisko and Kira board a shuttlepod and maneuver it between the comet fragments, generating a subspace field around the pieces as they travel through the wormhole. The pair is successful, as the fragments safely enter the Alpha Quadrant with just a minimum of the deadly material leaking into the wormhole. Amazingly, the material also forms a subspace filament which allows transmissions to come from the Gamma Quadrant. Kira realizes that the prophecy has come true — the symbolism was just interpreted incorrectly. The "vipers" were actually the comet fragments, which permanently wedged open the "temple gates" of the wormhole. Sisko returns to the station with new respect for Bajoran prophecy, and for his own prophesized role in Bajor's fate.