Earth was invaded in 2017 by an alien A.I. called "The Tet." The Tet used a cloned NASA commander for its troops, destroyed the moon and then sucked off Earth's resources. 60 years later, some of the clones are repairing the A.I.'s military drones and one of them is convinved by human survivors to blow up the A.I. in orbit around Earth.
60 years before the events of the movie, a huge extraterrestrial tetrahedral object was discovered in the vicinity of Saturn's moon Titan. Jack (Tom Cruise), his wife Julia (Olga Kurylenko) and Victoria (Andrea Riseborough) were part of the team sent there by NASA to examine the object. Jack and Victoria were captured, shortly after he ejected the rest of the crew (including his wife) that was suspended in "Delta Sleep" (stasis) to save them. The object, called "The Tet" which in reality is a huge (and mostly empty) alien artificial intelligence, then cloned Jack and used thousands of him to invade earth. To help its cause, it also destroyed the moon, causing huge tidal waves and earthquakes, destroying most of the planet. After conquering Earth, some cloned Jacks and Victorias were stationed on earth as "teams", to repair the A.I.'s automated drones that are protecting huge hydro converters that are sucking seawater from the oceans to convert them to energy used by the huge A.I. craft. All repair clones don't know of the other clones, protected from each other by supposed "radiation zones" they are not allowed to enter and are also told that alien "scavengers" invaded earth, but Earth won that war. The supposedly surviving population of Earth is on-board The Tet, waiting for travel to Titan where an Earth colony was established, and just needing the fuel from the hydro converters...
Repair clone 49 is then observed being interested in books lying around in the rubble by surviving humans, the alleged scavengers. Their leader Beech (Morgan Freeman) installs a beacon signal for the craft that still holds the original Jack's crew in a safe orbit, bringing the craft down for Jack to rescue it, thus convincing him to help their cause. He still has memory fragments from a visit to the Empire State Building where he proposed to Julia, making him believe the true story of what happened to Earth told by Beech and helping them to send a fuel cell from one of the drones up to the alien ship for detonation. Julia proposes to go with him and he tricks her by letting her go to delta sleep in her sleep pod, but in reality taking Beech with him in another pod who would've "liked to see their faces" when the enemy is blown up.
In the end, they confront the A.I. (a large, hovering pyramid with a HAL-like glowing red eye) talking about a tale from ancient Rome where a single man named Horatius Cocles held a bridge against an army to protect the city, then detonating the fuel cell which kills them and destroys the aliens craft.
Three years later on Earth, Julia (and her 3 year old daughter) is finally found by clone 52 who was knocked out in an encounter with clone 49 before, reuniting her with (a) Jack.