Image caption An illustration shows the night sky 3.75 billion years from now. Andromeda (left) fills the field of view and begins to distort the plane of our Milky Way Galaxy

Astronomers have used the Hubble Space Telescope to work out when precisely our Milky Way Galaxy will crash into its neighbour, Andromeda.

The pair are being pulled together by their mutual gravity and the scientists expect them to begin to merge in about four billion years' time.

A further two billion years on and they will appear as a single entity.

Our Sun's position will be disturbed but the star and its planets are in little danger of being destroyed.

Viewed from Earth, however, the night sky should look fairly spectacular. That is assuming, of course, that a human species is still around billions of years into the future to look upwards.

For the very first time, we've been able to measure the sideways motion - in astronomy, also known as proper motion - of the Andromeda Galaxy Roeland van der Marel, Space Telescope Science Institute

"Today, the Andromeda Galaxy appears to us on the sky as a small fuzzy object that was first seen by ancient astronomers more than one thousand years ago," said lead researcher Roeland van der Marel from the Space Telescope Science Institute in Baltimore, US.

"Few things fascinate humans more than to know what our cosmic destiny and future fate will be. The fact that we can predict that this small fuzzy object will one day come to engulf and enshroud our Sun and Solar System is a truly remarkable and fascinating finding."

Light-years apart

It has long been known that the two galaxies have been heading in the general direction of each other.

They are separated by about 2.5 million light-years, but are converging at something like 400,000km/h (250,000mph). The new Hubble data provides fresh insight on when and how a union is likely to unfold.

This is possible because the orbiting observatory has measured in finer detail than ever before the motions of select regions of Andromeda, also frequently referred to by its catalogue name M31.

"It's necessary to know not only how Andromeda is moving in our direction but also what its sideways motion is, because that will determine whether Andromeda will miss us at a distance or whether it might be heading straight for us," explained Dr van der Marel.

"Astronomers have tried to measure the sideways motion for over a century. However, this was always unsuccessful because the available techniques were not sufficient to perform the measurement.

Image caption In four billion years from now, Andromeda is tidally stretched and the Milky Way becomes warped

"For the very first time, we've been able to measure the sideways motion - in astronomy, also known as proper motion - of the Andromeda Galaxy using the unique observational capabilities of the Hubble Space Telescope."

Computer simulations based on Hubble's data indicate the two great masses of stars will eventually shape themselves into a single elliptical galaxy similar to the kind commonly seen in the local Universe.

However, although the galaxies will plough into each other, individual stars will not collide because the space between them will still be huge.

Nonetheless, the gravitational disturbance will shift the location of our Solar System, the researchers believe.

It is likely also that the merger will kick off a vigorous phase of new star formation as gas clouds are perturbed and collapse in on themselves. And the supermassive black holes at the centres of the galaxies will become one.

In addition, from their observations, the scientists say it is quite possible the Triangulum Galaxy (also known as The Pinwheel or M33), the next largest in the local group, will join the fray as well.

Image caption In seven billion years, the merger forms a huge elliptical structure with a bright core

Whether anyone will be around to witness these events is an open question.

In four billion years' time, our star will be running low on its nuclear fuel and will have begun to swell, says Dr van der Marel.

"Due to the natural evolution of the Sun, it will get slightly hotter over time and a few billion years from now it will have got sufficiently hot to make life [on Earth] as we know it impossible," he told reporters.

"But since we are talking billions of years into the future, I personally do not think that means our civilisation will not be there.

"For example, if we find a smart way to use solar energy and turn it into air conditioning, we may still be able to live on this planet."

Jonathan.Amos-INTERNET@bbc.co.uk and follow me on Twitter