Daedalus is returning from Earth with Weir and Sheppard on board. Sheppard has been promoted to Lieutenant Colonel and is quite happy to keep reminding Weir about it. They're interrupted by news of an accident: one of their team, Dr. Monroe, is dead. Beckett can't tell how Monroe died but it seems he was electrocuted. McKay brings up the footage but the camera malfunctioned right before he was killed. He recommends they drop out of hyperdrive but Caldwell overrides him and Weir.
We find out that when they were on Earth meeting with Landry, more personnel were authorized and they tried to put Caldwell in charge. Weir used her authority to get Sheppard promoted and left in charge of the Atlantis military contingent. McKay meets with Caldwell and confirms that the two incidents, the death and the camera malfunction, aren't part of the same accident, and that Monroe was working on computer security protocols. McKay and the Asgard, Hermiod, start checking the computer files but the ship's systems start malfunctioning and poison gas is released. One of McKay's coworkers, Lindstrom, is forced to take refuge in an airlock which then opens, killing him. Lindstrom apparently found out something before he died, and the crew suspects someone on board is responsible. Caldwell orders all of the civilians be confined to quarters, and we find out that Weir and Beckett worked together to assemble an expanded team.
Weir remembered that her fiancé, Dr. Simon Wallis, refused to sign up. When she confronted him on it, he was reluctant to give up his commitments and wanted some more time to consider. Hermiod detects a virus in one of the navigation computers, a non-human one that is rewriting and adapting itself. McKay determines it's a Wraith program, which remained dormant until they returned back toward Wraith territory. The virus is an AI program and it protected itself by killing Monroe and Lindstrom. McKay figures out that the virus can't get into every computer but it can control navigation. The virus then sends out a distress call. It can't yet fly the ship but it can call the Wraith to them. McKay suggests they wipe the system and restore from back-up, but it'll take time.
Sheppard takes a fighter out and blows up the main transmission array but when he tries to return his controls don't respond and his ship heads away at high speed. The virus uploaded itself into the fighter's systems but they manage to beam him out before he gets out of range. However, they can't lock on because the Asgard sensor was in the array that Sheppard destroyed. With time running out and Rodney improvising from the original range-detection system, Sheppard considers how he met with Ford's cousin to tell her of his fate and how he plans to find him. They manage to beam Sheppard back intact and then McKay initiates the shutdown.
Meanwhile Weir remembers how Simon decided to stay on Earth and let her go without him. He also admitted that he met someone else and he and Elizabeth part ways. Daedalus comes out of hyperdrive and starts to move from its position at sublight, but the virus (which they didn't entirely clear out) takes over and puts them on a collision course with the nearest star. They determine the ship is going to make a near-sweep of the sun to wipe out any living beings, and then take the ship to the Wraith. McKay recalls a similar incident back at SGC on Earth and concludes the virus is hiding in one of the fighters, so they pull the memory chips from there and shut down again and hopefully destroy the virus. They head for the fighter bay but the virus cuts off all approaches, so they try to use the teleporter, which wasn't designed for intraship beaming. It works and they get McKay and Sheppard into the fighter bay, but the virus opens the bay doors, but Hermiod counters by raising the force field, buying them a little time before the virus overrides the shield controls.
They quickly go to work removing the memory cores while the virus overrides the teleportation system and starts dropping the force field. McKay and Sheppard manage to take refuge in a fighter. They have only minutes left as they initiate another shutdown and reinitialize. They briefly gain navigational control but lose it again, and Sheppard figures out it's on the computer on the fighter he was beamed out of earlier, which is now tailing them. Sheppard launches the fighter that they're in, much to McKay's distress since they don't have a navigational computer. The virus-controlled ship locks on and Sheppard takes evasive maneuvers then tries to close in as it flees into the sun's coronasphere. He intercepts and destroys it then gets out just ahead of the heightened radiation levels.
They get back to Atlantis and the new folks start moving in while Rodney worries about radiation poisoning and everyone gets back to work.