The Last Man

"The Last Man" is the twentieth episode of Stargate Atlantis' fourth season and is the season finale.

Plot
John Sheppard returns to Atlantis after an off-world mission in the continuing search for Teyla and finds the city abandoned, all systems dead -- and instead of ocean surrounding the city, sand dunes as far as the eye can see. Sheppard is greeted by the hologram of an elderly Rodney McKay and discovers that he has been taken 48,000 years into the future. Now, as the last man in the city, and perhaps the galaxy, he must uncover the reason for this strange turn of events.

McKay's hologram, following the programming made by McKay 48,000 years in the past, tells Sheppard of McKay's plan to send Sheppard back into the past via the interaction of a wormhole and a solar flare. However, the plan involves putting Sheppard into stasis for hundreds of years until an appropriate solar flare is detected. While they make their way through the abandoned city to the stasis chamber, McKay's hologram describes the events that followed Sheppard's mysterious disappearance. The hologram tells a story of a series of disasters in the Atlantis expedition's efforts to stop Michael (see Misbegotten) in his ruthless ascent to hegemony in the Pegasus galaxy. This account of events occupies much of the episode.

The hologram tells of how Teyla was finally found dead by an Atlantis team; it is clear that Michael had taken her baby for his purposes and killed her.

Colonel Samantha Carter was killed in action on a desperate mission aboard the newly constructed battlecruiser Phoenix to stop Michael's extermination and enslavement of human populations.

Ronon Dex left Atlantis to gather an army from native Pegasus populations to oppose Michael's forces. Ronon sacrificed himself to complete a mission to destroy one of Michael's Wraith laboratories. In a poignant coincidence, the wraith Todd (see Common Ground ep 3.7) died fighting alongside Ronon.

McKay, along with Jennifer Keller, grew disgusted with the new leadership of Atlantis; the IOA ordered the Atlantis team to focus solely on the defense of Atlantis, leaving the Pegasus galaxy to Michael's devices. On their way back to Earth aboard the Daedalus, a romance flourished between McKay and Keller, only to be cut short when Keller died soon afterward on Earth from exposure to the Hoffan drug (see Poisoning the Well).

McKay devoted the rest of his life to finding a way to return Sheppard from the future Atlantis so that Sheppard would be able to alter the entire timeline of events, hopefully for the better.

In the next scene, Sheppard successfully returns to Atlantis 12 Days after his disappearance. After explaining the situation to his confused and skeptical team, he convinces Carter to send a strike force to the planet where Sheppard knows Michael was planning to kill Teyla. The episode ends as they arrive to find they have beat Michael to the location, only to set off a booby trap that takes down the entire building around them.