On July 2, an enormous alien mothership enters orbit around Earth and deploys 36 saucer-shaped destroyers, each of which is at least 24 km wide, over major cities around the globe. In New York City, David Levinson discovers transmissions that he believes the aliens are using as a countdown to coordinate an attack. David and his father Julius travel to the White House and warn U.S. President Thomas J. Whitmore of the attack. The President, portions of his Cabinet and the Levinsons narrowly escape aboard Air Force One as the alien spacecraft destroy Washington D.C., New York City, Los Angeles, and other major cities around the world with energy-based weapons.
Meanwhile, USMC Captain Steven Hiller is called to take part in a counterattack against the aliens. His girlfriend Jasmine, her son, and their pet dog survive the attack by hiding in a workmen's shed in a Los Angeles freeway tunnel. The next day, on July 3, Jasmine uses a maintenance truck in an effort to reach Hiller's base and finds several survivors. She also finds the injured First Lady , who had been in Los Angeles and whose helicopter was brought down by the alien attack.
On the same day, as part of a U.S. counterattack, Captain Hiller leads a squadron of F/A-18 Hornets on a mission to engage with a destroyer near the remains of Los Angeles. The destroyers are revealed to be guarded by force fields, which repel projectiles and nuclear detonations, and it releases scores of smaller "attacker" ships armed with similar shields and weaponry. After a one-sided dogfight ensues, resulting in the destruction of Hiller's base, Hiller survives by luring an attacker to the Grand Canyon, where he causes it to crash and then subdues the alien pilot. Hiller is picked up in the desert by a refugee group that includes Russell Casse , an alcoholic crop-duster who has claimed that he was abducted by the aliens ten years previously. They take the captured alien to Area 51, where Air Force One has already landed. Area 51 conceals a top secret facility housing a repaired attacker ship and alien bodies recovered from Roswell in 1947. The captured alien regains consciousness at an Area 51 lab, kills the scientists examining it, and attempts a psychic attack against Whitmore, but is shot and killed by his entourage, although not before Whitmore gains an idea of the species' goals, describing them as locusts that travel from planet to planet, harvesting a planet's resources before moving on. A retaliatory attack using a AGM-86 air-launched cruise missile with a W80 nuclear warhead against a destroyer over Houston ends in failure. Hiller goes to the remains of his base and finds Jasmine, the First Lady and the other survivors, and brings them back to Area 51. The President and his daughter, Patricia, later visit the First Lady when she is in the hospital, and it is revealed that she suffered mortal internal injuries in her helicopter's crash. The President stays with her for the last few minutes of her life. After he leaves the room, he and Patricia hug and comfort each other.
On July 4, David devises a plan to use the repaired attacker to gain access to the interior of the mothership in order to introduce a computer virus and plant a nuclear device. It is hoped that this will cause the shields of the Earth-based alien craft to fail long enough for a worldwide attack to eliminate them. Hiller volunteers to be the pilot of the attacker ship for the mission— reasoning that he is the only person to have seen the ships in action and survived, thus giving him unique knowledge of their capabilities and thus the only person with a chance of operating it—, with David accompanying him to upload the virus. With few pilots to man available aircraft, the battle requires volunteers, including Whitmore and Casse, who both have previous combat flight experience as former fighter pilots. Morse code is used to contact forces around the world in order to coordinate the attack.
Upon entering the mothership, David and Hiller discover the aliens are preparing to launch an invasion. After the virus is implanted and lowers the shields, Whitmore leads an attack against a destroyer approaching Area 51. Although the fighters can now damage the alien ship and the attackers, their supply of missiles is exhausted against the craft's large complement of attackers while its sheer size makes missiles relatively ineffectual against it directly, and the destroyer prepares to fire its main weapon at the base. Casse possesses the last remaining missile, but his firing mechanism jams. He then pilots his aircraft into the center of the alien weapon in a suicide attack, causing a chain reaction which destroys the alien ship.
The U.S. informs other forces around the world about the method, and they are able to use it bring down the remaining destroyers. Meanwhile, David and Hiller are discovered aboard the mothership, but they fire the nuclear bomb and escape the mothership just as it is destroyed, and the duo crash-land near Area 51. The world celebrates, and the main characters watch debris from the mothership enter the atmosphere.