Scrat, trying to bury his acorn, accidentally activates an abandoned alien ship that takes him into deep space, where he unwittingly sends several asteroids en route to a collision with Earth. Meanwhile, Manny is worried about the upcoming marriage between Peaches and her fiancé, Julian. Diego and his wife Shira want to start a family, but their fierce appearance tends to scare kids. Sid is dumped by his girlfriend, Francine, just as he is about to propose to her, and he laments his solitude. During Manny and Ellie’s wedding anniversary party (which Manny had forgotten prior to the event), some of the asteroids strike the place and the herd barely escape with their lives. Meanwhile, at the underground cavern, Buck returns a dinosaur egg back to its rightful owner after it was stolen by a trio of dromaeosaurs named Gavin, Gertie, and Roger. Buck discovers an ancient stone pillar and takes it to the surface, where he meets Manny and the others.
Buck explains to the herd that according to the pillar, the asteroids had caused several extinctions in the past and with a massive one still incoming, he believes that the only place they could find a clue to stop it is on the site of the impact of the previous ones, as according to its engravings, they always fall at the same place. However, the three dromaeosaurs overhear their conversation, and Gavin and Gertie decide to stop them, believing that they could be safe from the impact, as they can fly, thus not only getting their revenge on Buck, but also killing all mammals and securing domination over Earth for their species. Roger is reluctant, but Gavin and Gertie strong-arm him into cooperating.
As the herd travels to the crash site, they discover that the asteroids have electro-magnetic properties. Buck theorizes that if a huge quantity of smaller asteroids should be gathered and launched into orbit, they could attract the main asteroid as well and prevent it from falling on Earth. After facing several obstacles and the interference of the dromaeosaurs, the herd arrives at “Geotopia”, a community of immortal animals formed inside one of the asteroids that have fallen long ago, where Sid meets Brooke, a female ground sloth who falls in love with him. However, Shangri Llama, the leader of Geotopia, refuses to cooperate with Buck’s plan to send the city’s crystals into space in order to prevent the imminent impact, as they are the key to the residents’ longevity. Sid inadvertently destroys the entire city when he attempts to remove one of the crystals to present Brooke with, immediately aging them to their real ages and revealing their true crone-like appearances.
Once Brooke convinces the Geotopians that preventing the asteroid’s fall is more important than their lost youth, they and the herd help with Buck’s plan, which is to fill up a geyser with the crystals so that the pressure launches them into space to draw the asteroid away. The dromaeosaurs attempt to intervene, but Buck convinces Roger that they will not be able to survive the asteroid, and he in turn convinces Gavin and Gertie to help. The plan works, and the asteroid is pulled back into space. The herd then departs back home, including Sid, who parts ways from Brooke, but just after they leave, an asteroid piece falls inside a hot spring, giving it rejuvenating properties and making the Geotopians and Sid’s grandmother, who stayed behind with them, regain their youth. After the herd returns, Manny reconciles with Julian, Peaches and Julian celebrate their wedding, Diego and Shira become heroes to the kids who were scared of them before, and a rejuvenated Brooke appears during the ceremony to reunite with Sid.
In the film’s epilogue, Scrat keeps struggling to control the alien ship until it crashes on Mars, destroying all life on the planet.
In a mid-credits scene, Scrat finds his acorn, but gets beaten by some doors.