Given the inexorable increase in the Sun's luminosity, Earth will exit the habitable zone in ~1 Gyr. There is a negligible chance that Earth's orbit will change during that time through internal Solar System dynamics. However, there is a ~1% chance per Gyr that a star will pass within 100 au of the Sun. Here, we use N-body simulations to evaluate the possible evolutionary pathways of the planets under the perturbation from a close stellar passage. We find a ~92% chance that all eight planets will survive on orbits similar to their current ones if a star passes within 100 au of the Sun. Yet a passing star may disrupt the Solar System, by directly perturbing the planets' orbits or by triggering a dynamical instability. Mercury is the most fragile, with a destruction rate (usually via collision with the Sun) higher than that of the four giant planets combined. The most probable destructive pathways for Earth are to undergo a giant impact (with the Moon or Venus) or to collide with the Sun. Each planet may find itself on a very different orbit than its present-day one, in some cases with high eccentricities or inclinations. There is a small chance that Earth could end up on a more distant (colder) orbit, through re-shuffling of the system's orbital architecture, ejection into interstellar space (or into the Oort cloud), or capture by the passing star. We quantify plausible outcomes for the post-flyby Solar System.