Disclaimer: no fear-mongering was intended in this article, so I apologize in advance if humanity's future at a glance seems a bit bleak.

But it is very possible that, at some point in the future, a devastating cosmic event could wipe out human civilization—along with the majority of life on Earth. Here's a look at the rough timeline estimates for some of these events:

Within Thousands of Years: An Asteroid Impact

In the long and storied history of Earth, we've bumped into at least a few space rocks. Billions of years ago, we were hit by a protoplanet the size of Mars—from that impact formed the Earth's Moon. Then, 65 million years ago, an asteroid at least 10 kilometers in diameter smashed into Mexico and wiped out the dinosaurs. Some scientists theorize that a large impact 12,900 years ago may have been responsible for the extinction of many large mammals, including the woolly mammoth and sabre-toothed tiger—as well as wiping out a significant percentage of humans inhabiting North America.

Arizona Meteor CraterA giant impact crater in Arizona, possibly coming to a city near you... Image: Shane Torgerson.

And there have been more than a few smaller asteroids that have exploded in the atmosphere in recent memory. In 1908, an asteroid as large as 100 meters in diameter exploded over Siberia and flattened half a million acres of forest—an area larger than most modern cities. More recently, in 2013, an asteroid 20 meters in diameter exploded over Chelyabinsk, Russia, causing minor injuries to some 1,500 people.

An object one kilometer in diameter would be enough to destroy a small country, killing millions. And the after-effects of such an impact could be even worse.

Apart from leaving a large impact crater and an outward radius of devastation, a large enough impact could launch a huge amount of dust and debris into Earth's atmosphere. This dust would block sunlight from reaching the surface of Earth, essentially causing a global nuclear winter that could last years. Global temperatures would plummet and photosynthesis would grind to a halt. Lack of food would lead to the extinction of most large mammals, and billions of human beings would likely starve to death.

Fortunately, investment in near-Earth asteroid detection has been increasing steadily over the past decade. It's still not quite enough to reach the U.S. goal of having identified 90% of all asteroids 140+ meters in diameter by 2020, but funding is trickling in and scientists are identifying more near-Earth objects (NEO's) per year than ever before.

Every few months, social media is flooded with headlines proclaiming that a large space rock will just miss Earth in a few days' time, but most of these 'near misses' pass by at least a few million kilometers away. And it's not that these events are suddenly occurring more frequently, but rather that we now have enough eyes in the sky that we can actually detect a significant percentage of these rocks before they reach us. But not all.

Comet 67PA close-up image of Comet 67P captured by the Rosetta spacecraft. Image: ESA/Rosetta/NAVCAM.

There's always the possibility that a large asteroid could be looping around out of our line of site (ie. behind the Sun), sneaking up on our fragile planet while we're not looking. As scary as the idea of a random space rock falling on our heads from the sky on any given day is, this is something that we can control. With a bit more funding and development of deflection strategies (NASA is currently trying to figure out how to capture a small asteroid and bring it into orbit around the Moon), asteroid impacts are about the only cosmic disasters that we have the capability of avoiding.

That is, if we're prepared for it. If given enough notice (four years would be ideal, one would be pushing it), it's well within our technological capability—and part of our responsibility as a species—to deflect a large asteroid that's en route to be delivered to Earth by the great cosmic mailman: Gravity.

Within Millions of Years: A Nearby Supernova

As Earth completes one full orbit of the Milky Way galaxy every 200-250 million years, our stellar neighbors come and go. Some stars move further from us, some come nearer—sort of like vehicles traveling along a highway at different speeds and in different lanes.

We know that there are certain regions of the galaxy in which star formation occurs at a higher frequency, in which supermassive stars are more common, and in which supernovae explosions happen at a higher rate. Unlucky for us, our solar system is just entering one of these regions—the Milky Way's Orion arm—where a close encounter with an exploding supernova becomes much more likely.

Artist Rendering of a SupernovaAn artistic rendition of Supernova 1993J, located 8.5 million light years from Earth. Image: ESA/Hubble.

Whereas our Sun has a total lifespan of around 10 billion years, these big, hot, young, blue-colored stars have a lifespan lasting only a few million years. And when they die, they do so spectacularly: a supernova can release more energy in an instant than our sun will over its entire 10 billion-year lifespan.

If one of these stars happened to explode within 50 to 100 light years of Earth, a shower of radiation would devastate Earth's Ozone layer. With that layer of protection compromised, ultraviolet radiation from the Sun would begin to ravage life on Earth, breaking down biological molecules and greatly increasing risk of cancer among humans.

It's been estimated that one of these supernovae occurs near enough to impact Earth once every 15 million years or so. Another estimate places a supernova within 33 light years of Earth occurring roughly every 240 million years (one complete orbit of the Milky Way), near enough to destroy 50% of the Ozone layer and cause mass-extinction of life on Earth. Some theories even suggest that various mass-extinction events in Earth's distant past were caused by near-Earth (in cosmic terms) supernovae.

Fortunately, there don't seem to be any supernova candidates near enough to cause Earth any harm for the time-being. But there are some really big stars further out that could potentially produce a powerful gamma-ray burst if/when they explode in a supernova or collapse into a black hole.

Gamma rays are released as very narrow beams of ultra-intense radiation focused on a very small region of space, sort of like a laser-pointer. If Earth happens to fall within the target of one of these beams, and is close enough to be effected (most observed gamma rays are billions of light years away and harmless), then it's possible that life on Earth could be just as devastated by gamma-rays as by supernovae—but from 10,000 light years away rather than just 100.

Crab NebulaThe Crab Nebula is the remnant of a 1,000 year-old supernova. Image: NASA, ESA, J. Hester & A. Loll (Arizona State University).

In sum, supernovae are rare and easy to predict using Earth-based telescopes, whereas gamma-ray bursts can occur without warning and are somewhat like winning the lottery (of cosmic disaster). But given the extremely long amount of time in which the Earth will continue to whirl about the galaxy, in and out of supernova hot-zones, it's highly likely that we'll encounter one of these interstellar explosions at some point in the distant future. Alas, let the mutations begin.

In less than a Billion Years: The Sun Burns Hotter

Our Sun is a constant nuclear explosion generating just enough energy at just the right distance so as to allow liquid water to exist on Earth without freezing solid or evaporating into a gas. When the sun formed some 4.56 billion years ago, it only generated about 70% as much energy as it does today. As time went on, solar energy production steadily increased by a rate of approximately 1% every 110 million years.

The bad news is that this trend will continue into the future. And as the sun produces more energy, the habitable zone around it moves further and further away. In one billion years, the sun will be shining about 10% brighter than it is today.

A side-effect of this increased solar luminosity is an increase in ultraviolet radiation, which is devastating for atmospheric carbon dioxide levels. Increased solar energy will cause Earth's surface to weather more rapidly. As silicate minerals in Earth's crust decay faster, they capture carbon dioxide gas out of the atmosphere at a higher rate, forming solid carbonates. This increased rate of carbon capture will eventually throw the planet's carbon cycle out of balance.

The SunThe Sun as it appeared on February 18, 2015. Image: NASA/JPL/Cornell.

In as little as 500 million years, Earth could be facing an environmental crisis in which there's not enough carbon dioxide in the atmosphere to sustain plant photosynthesis. A potential fix for this is that, in the distant future (long after we've all switched over to electric cars), we may need to purposely burn additional fossil fuels in order to counteract the carbon being taken out of the Earth's atmosphere as a result of ultraviolet radiation. If plants are starved for carbon dioxide and unable to undergo photosynthesis, then the food chain would collapse out from under us and everyone on Earth would starve to death.

Another effect of increased ultraviolet radiation will be steadily increasing global temperatures, regardless of whether or not we add carbon dioxide to the atmosphere. Rising temperatures will eventually evaporate all of the liquid water on Earth's surface—including the oceans. Without some kind of intervention, liquid water may cease to exist on Earth's surface in as little as one billion years, transforming our blue oasis into a desert wasteland.

One possible fix for increasing levels of solar luminosity may be adding reflective particles, such as gold, to the atmosphere in order to reflect the additional sunlight reaching Earth. Small quantities of gold particles shouldn't cause any problems to currently existing life on Earth, and if added gradually over a long time period, life would be able to adapt to atmospheric gold levels over time.

Surviving on Earth will become much more difficult in the distant future than it is today. Creating a human settlement on Mars and developing advanced geoengineering technologies will be vital to maintaining the habitability of our planet (and other habitable worlds) going forward. Although we don't yet fully understand the effect humanity is having on our global environment, advancements in Earth and planetary sciences going forward will be key to humanity's future—on Earth and beyond.

In about 4 Billion Years: Colliding Galaxies

About 2.5 million light years away from Earth is the Andromeda spiral galaxy, containing somewhere between two and five times as many stars as our Milky Way spiral galaxy. And it's moving rapidly towards us.

4 billion years from now, Andromeda and the Milky Way are set to collide with one another and eventually merge to form an even larger elliptical or disc galaxy (which has yet to be given a name... maybe "Milkdromeda?"). The transformation of our galaxy will be profound, and it's possible that our solar system could be ejected into intergalactic space or even torn apart by a close-encounter with a black hole or another star.

Andromeda GalaxyThe Andromeda Galaxy: rapidly advancing towards a galaxy near you. Image: Adam Evans.

If Earth were ejected from the solar system during this clash of galaxies, life would not survive long without the sun. Humanity would need to abandon Earth in search of a new, more stable home. There is a very small chance that Earth, if ejected, could be captured into the orbit of another star—but it's highly unlikely that it would be captured into another habitable zone, and even less likely that the Earth wouldn't become a frozen wasteland of ice and rock long before then.

An alternative to this is that other planets could become destabilized by passing stars and have their orbits around the sun severely altered, or the Oort Cloud at the boundary of the solar system could be jostled and some of its trillions of comets sent hurling towards the sun, potentially slamming into Earth in the process.

Another byproduct of this galactic collision will be new neighbors and a real-estate flash-sale. As stars settle into their new orbits around the newly formed galactic core, new star formation in the jostled-up galaxy will increase dramatically. Higher numbers of supermassive stars will form, which will in turn increase our chances of having a close encounter with a deadly supernova.

By far the most turbulent and unpredictable time in Earth's future, survival in this new super-galaxy will be challenging. Luckily, all of the problems outlined above will have already been encountered and overcome by human civilization in the past, so our ability to rapidly adapt to changes may win us our future—as will our ability to abandon our solar system if need be.

In about 5 Billion Years: The Death of our Sun

If Earth hasn't yet been ejected from the solar system or transformed into a desert wasteland, then it will unquestionably meet a fiery end some 5 billion years in the future, when our Sun runs out of hydrogen. At this point in solar evolution, the Sun will enter its red giant phase, expanding to 256 times its current diameter as it shifts from burning hydrogen to burning helium. Helium burns hotter and faster, causing the sun to produce more energy in a shorter amount of time, thus causing it to balloon greatly in size.

Earth will either be engulfed within the Sun's corona or remain just barely outside of its radius. In either case, it's surface will be turned into magma and its outer layers stripped until only its metallic core remains—which will probably then be consumed by the red giant as a midnight snack, subsequently increasing its metallicity by about 0.01%. Everything on Earth will be completely destroyed via hellfire.

Red GiantThe Sun will get way bigger in 5 billion years. Image: Oona Räisänen.

But in order for humanity to even survive until this point, we will first need to a) detect and deflect civilization-ending asteroids, b) somehow avoid environmental destruction via supernovae and gamma-rays, c) re-engineer Earth's environment to continue sustaining life, and d) survive the merging of Andromeda and the Milky Way galaxies.

After having gone through all of that drama, any surviving human civilization will then need to figure out a way to survive Earth's being engulfed by the expanding Sun. The only way to do so will be to pick up and leave the planet—either for another planet in the solar system or another solar system entirely.

As the Sun expands outwards and begins to warm some of the moons around Jupiter and Saturn to habitable levels, it's possible that humanity could briefly eek out some sort of existence on a moon like Europa. But any sort of life on these outer moons would only be temporary; the Sun will eventually transition into a white dwarf phase, during which it will emit very little energy.

The ultimate fate of humanity is to either go extinct or find a new star to call home, perhaps even setting ourselves up as a roving band of star-hoppers. Regardless of whether or not humanity survives to see the sun swallow the Earth, it will eventually happen with certainty.

Perhaps the best thing we can do in the meantime is to catapult ourselves as far out into space as possible—to the Moon, to Mars, to the outer moons of Jupiter and Saturn, and eventually even to another star system.