Sometime between the next 3 to 5 billion years, the Andromeda galaxy and the Milky Way galaxy will probably collide with each other. This collision between the 2 largest galaxies in the Local Group will bring more than 2 hundred billion stars into close proximity.
However, close proximity in galactic terms is still a very long distance away. Distances between even nearby stars are unimaginably huge. Even if the 2 galaxies collide directly, there should be plenty of room for nearly all stars to pass by each other, although they will interact gravitationally with each other.
Will they collide at all?
No one is completely certain how directly the galaxies will collide, or even whether there will actually be a collision or not. This is because the Doppler shift can only measure if something is getting closer or further away, or radial velocity. The Doppler shift cannot measure side to side movement, or transverse velocity. The only methods of measuring transverse velocity are indirect. Even a very small deviation in transverse velocity could cause the 2 galaxies to miss each other completely.
This means that it is known with good precision that the Andromeda galaxy and the Milky Way galaxy are moving towards each other by about 75 miles per second. That comes out to about 0.04 light years in each century.
Indirect measures of the Andromeda galaxy’s transverse velocity can be obtained by studying the behavior of its satellite galaxies. The best current estimates of transverse velocity are less than 62 miles per second, but no one knows exactly how much less. At close to that limit, this could be enough for the galaxy disks to miss each other, but would still cause the dark matter halos of each galaxy to collide in a galactic sideswipe. If the transverse velocity is close to zero, the galaxies will collide head-on.
There is even a good chance that the Milky Way and the Andromeda galaxy are in orbit around each other. However, the next close approach of this orbit or the one after that will probably be the last. The galaxies are simply coming too close to each other to survive. It is only a matter of time before they fall into each other and merge.
The results of collision
The only parts that are nearly certain to collide directly are the shockwaves each galaxy creates ahead of it. As those shockwaves approach each other, they will compress the interstellar dust clouds between the galaxies. This compression may trigger the birth of large numbers of new stars. Collision and compression of the dark matter halo will also cause new star birth.
Multiple CGI animations have been made of impending collisions which are close to head-on. Parts of this process have also been photographed elsewhere in the universe.
In each case, the center of each spiral galaxy contracts. This is a structural change which is caused by the interacting gravitational fields of large numbers of stars. At the same time, the tidal forces from the approaching galaxy force the spiral arms of the other galaxy into a tidal tail. This temporarily creates a spiral or bar galaxy with 2 spiral arms, but this is not a stable state.
The Earth is currently far out along one of the spiral arms of the Milky Way, so there is a good chance the sun will be among the first affected stars. Its position within the galaxy will change. It could remain temporarily linked to the Milky Way or it could be temporarily transfered to Andromeda. At some point, it will probably be flung close to the center of the Milky Way, on its way out to the edges of a tidal tail. Unless it passes too close to the galactic core, the Earth will probably end up roughly 3 times as far from the galactic center as it is today.
Galaxies which contain mostly stars and very little dust and dark matter would coelesce into a single elliptical galaxy over the course of a couple of orbits. Even so, this would take several million years. However, more typical galaxies, such as the Milky Way, contain at least 10% dust and gas, probably more. In this case, the gas is forced from more or less even distribution towards the galactic cores. There, it triggers a spurt of star formation, but most of those stars will probably be short-lived as stars go.
In any collision which results in galactic merger, the cores of the galaxies will interact gravitationally. It is now commonly accepted in the astronomic community that all galactic centers contain a supermassive black hole. These black holes will sink towards the center of the merging galaxy, where they will briefly orbit each other as they come closer and closer together. When they get within a light year of each other, they will merge with each other.
If enough dust and gas coelesces around the new black hole in an accretion disk, it will have the same brightness as a quasar. In fact, most quasars are thought to originate in this process.
None of this may matter to people on Earth. The sun will become a red giant in about 5 billion years, close to the same time when the Andromeda galaxy and the Milky Way galaxy are predicted to collide. Its radius will extend beyond Earth’s current orbit, although the Earth itself may escape being swallowed because its orbit will have moved further out. However, the temperature on Earth will definitely increase to the point that no liquid water can survive. If man has not colonized other stars by this point, mankind will go extinct.