******* WARNING : The below contents may contain SPOILERS *******
While fixing a satellite in orbit, the Space Shuttle Atlantis is destroyed by a meteor shower, killing the entire crew. Meteorites then bombard New York City and several other parts of the world, and NASA discovers that an asteroid the size of Texas, traveling at 22,000 miles per hour, will collide with Earth in 18 days, effectively destroying the planet. The scientists at NASA - in cooperation with the Russian, Japanese and other European space agencies - plan to detonate a nuclear bomb at a precise point under the asteroid's surface which will split it in two, and cause it to miss the Earth. However, the bombs must be planted at least 800 feet below the surface within eight hours of landing, and no later than four hours before the Earth impact. The mission is not revealed to the public, fearing panic.
NASA locates Harry Stamper (Bruce Willis), because he could help them drill a hole on the asteroid. When invited to NASA, Harry brings his daughter Grace (Liv Tyler) to keep her away from A.J. (Ben Affleck), a young, rambunctious member of his crew who, he has just discovered, has been sleeping with her. This disappoints and infuriates Harry because he did not want his daughter to marry an oil driller like himself or remain in the blue collar life. Head of NASA Dan Truman (Billy Bob Thornton) informs Harry of the dire situation. Harry recognizes that he and his crew must accompany the astronauts to ensure the job is done properly. After Harry's crew (Jayotis "Bear" Kurleenbear, Max Lennert, Rockhound, Oscar Choice, Charles "Chick" Chapple and some others) is collected and NASA acquiesces to their demands, they are put through a 12-day training program and outfit a drilling rig with the proper equipment.
After a meteorite strikes Shanghai, China, destroying the city and causing a tsunami, the incoming asteroid and pending mission are revealed to the world. Two military shuttles, Freedom and Independence, are launched and dock at a Russian space station (crewed by Lev Andropov) to refuel with liquid oxygen propellant. A.J. encounters a problem stopping the pumps after the ships' tanks are full and the station explodes. The crews and Lev Andropov escape. Later, the two shuttles perform a high G-force powered slingshot procedure around the Moon, traveling at 22,500 miles per hour to intercept the asteroid.
As they enter the asteroid's wake, the Independence is struck by debris and crash-lands on the asteroid, killing most of its crew, including Oscar Choice, Freddie Noonan and the Independence pilots. AJ, Lev and Bear survive. The Freedom lands on the surface but misses the target landing zone, arriving on an area of hard iron which will be difficult to drill through. The Freedom team tries to drill but suffers several setbacks and losses due to unexpected conditions.
After losing communication with Earth, the mission is put on hold, as the bomb's timer is activated by orders from the United States President to ensure the mission succeeds. However, a surface explosion would not be sufficient to divert the asteroid. Harry convinces Colonel Sharp to de-activate the bomb and help them attempt to finish the job. With just 250 feet left to drill, their drilling machine is blasted off the asteroid by a gas vent killing Max in the process. When the crew radio report to NASA that the mission has failed, worldwide panic ensues as humanity braces for the end of the world. A massive meteoroid then strikes Paris, destroying most of the city.
The Freedom crew learns that the other team managed to survive the crash thanks to Lev Andropov and A.J. and have driven the second drilling machine to the site. Harry puts A.J. in charge of finishing the drilling and they successfully drill to the necessary depth. The team lowers the nuclear bomb into the hole, but are caught in a rockstorm. The storm kills crew member Gruber and damages the remote on the bomb, rendering remote detonation useless. With 18 minutes left, Truman tells the team that someone must stay behind to detonate the bomb. A.J. is chosen after drawing straws, but Harry disables A.J.'s air supply and takes his place. As the shuttle departs, Harry sends a message to his daughter, giving his full support for her to marry A.J.
Harry detonates the bomb exactly at the deadline, causing the asteroid to split in two and miss the Earth by 400 miles, at the cost of his own life. The remaining crews of Freedom and Independence return to Earth as heroes. A.J. reunites with Grace while the others are met by their loved ones. Grace and A.J. soon marry, while Harry and the other lost crew members are memorialized.