Expansion of the Universe and collision with the Andromeda galaxy

One says that, in a couple of billion years, the Andromeda galaxy will collide with the Milky Way galaxy. How is this possible if the universe is expanding?

The velocity at which galaxies recede from us is proportional to their distance from us. The Andromeda galaxy is the closest to us (it belongs to the same cluster of galaxies, called the Local Group) so its recession velocity should be small. But this effect is opposed by the gravitational attraction of our local cluster of galaxies. The attraction wins over the expansion and Andromeda comes closer (the light it emits appears blue-shifted to us instead of red-shifted). On the contrary for distant galaxies, the recession velocity due to expansion is much larger. And the gravitational attraction is much smaller. Expansion wins.

1 2