Dr. McKay and his team (Dr. Zelenka, Lt. Ford, and Dr. Hayes) are playing a game of guessing if a given number is a prime number or not. They are one of the teams checking the city for damage after being hit by a major storm (see episodes The Storm and The Eye). McKay reports to Dr. Weir that the pier section they are inspecting is, from an engineering stand point, sound, if not dark and stinky. As they have met up with other team members and are about to head back, Zelenka notices that two team members are missing (Wagner and Johnson). McKay calls them on the radio, only to hear them yell they need backup.
Once they reach them, they find Wagner is dead and Johnson still alive but seeing things, and she dies soon thereafter. McKay calls for Dr. Beckett to send a containment team and tells his team they need to retrace Wagner and Johnson's steps. Some of the team balk at heading toward the unknown disease, but McKay explains that time is of the essence. If the disease is airborne they are already infected, and if it's bacterial they are ok if they don't touch anything. Peterson yells that he feels fine and that they should leave quickly. However, Beckett institutes a level 4 quarantine for that pier. No one can leave.
Dr. Grodin, in the control center, tells Weir that the unknown disease could be the plaque that killed the Ancients and they should be very cautious. McKay and team retrace the Wagner and Johnson's steps. They find a lab with broken containers that are the likely source of the unknown disease.
In another part of the city, Major Sheppard and Teyla find they are quarantined in the gym which they were exercising in. Weir refuses to let them out to help with the emergency.
Back in the Ancient viral lab, one of the team members starts to see things and then dies suddenly. Peterson also has a momentary hallucination, and during the confusion over the dead team member, sneaks out of the lab unseen. However, Ford quickly notices Peterson has left. Weir is able to spot Johnson on the internal sensors, and says they are locking the doors to block Peterson's movement. McKay tells Weir that Peterson has enough knowledge to get through the doors anyway, and that it's important to send someone to stop him. Weir also uses the com to try to convince Peterson to return to the lab, but he doesn't listen.
Beckett's hazmat team arrives in the lab to help McKay and his people. However, McKay is now starting to hallucinate too.
Back in the gym, Sheppard orders Sgt. Bates to open the doors, overriding Weir's orders for Bates not to. Bates finally opens the door letting Sheppard and Teyla out. They go to a med lab and don hazmat suites and go after Peterson, who is still slowly moving away from the viral lab. Sheppard and Teyla are able to track Peterson down, and Peterson agrees to go to the med lab, but not back to the viral lab. When their guard is down, he bolts to a transporter before he can be stopped. In the process, Sheppard shoots a stream of bullets at Peterson, hitting him once in the shoulder. The transporter takes Peterson to the mess hall, where there are a handful of people. Peterson is now in the part of the city where the city itself can detect the disease. The city automatically locks all the doors, including the transporters, preventing Sheppard and Teyla from following. However, Sheppard and Teyla find that the city will allow them access through some doors because they are protected by their hazmat suits from the disease.
McKay thinks he is about to die (due to the timing of the other deaths) and starts to give his last thoughts. However, he doesn't die when expected, and the thought is that the earlier injection of the Ancient gene may have protected him.
The autopsies that have now been performed show the virus' effects are too specific; that it must be a nano-virus designed to kill humans only, through brain hemorrhages. They also determine the nano-virus can not replicate itself and will eventually become too spread out to kill anyone.
Because the nano-virus is basically a computer, it is decided the solution is to set off an electromagnetic (EM) pulse. This should disrupt all running computers and thus kill the virus. All the SGA computers are turned off as they are not shielded, but McKay says the Ancients' technology won't be affected as they use crystals instead of circuits. McKay talks Sheppard through setting off a generator to create an EM pulse. Once the pulse goes off, they realize it didn't work because the city wouldn't return control to them.
Sheppard believes that what is needed is to detonate a Naquadah generator 20 miles above Atlantis; that this would generate a large enough EMP to destroy the entire virus. McKay agrees, but Weir is hesitant. Nevertheless, she finally agrees and the resulting burst does indeed destroy the virus, and the city returns to normal control.
At the end, McKay and Beckett tell Weir and Sheppard that the nano-viruses were not created by the Wraith as thought, and that they should hope whoever created this nano technology is not still around.