“Civil Defense” is episode seven of season three of Star Trek: Deep Space Nine.
Chief O’Brien, assisted by Jake, is converting one of the old refineries on the station to a new use when they accidentally trigger an old defence mechanism. The ship’s computer is under the impression that the Bajoran workers in the refinery are revolting, and O’Brien, Jake and Sisko end up trapped inside.
A recording of Gul Dukat tells them to hand themselves over to Cardassian security. However, there aren’t any Cardassians any longer, so this isn’t possible, and the three will wind up gassed. They manage to escape, but that unfortunately puts the entire station under lockdown.
With the computer now thinking that Bajoran prisoners have escaped, it’s going to gas all the Bajorans on the station. Unfortunately, this causes the computer to set up a self-destruct mechanism.
Gul Dukat arrives, and attempts to bargain before he disarms the self-destruct, but he ends up trapped on the station as well, where he has a nice little chat with Garak. They don’t like each other much.