M51 is actually two galaxies. The larger galaxy (M51A) is designated NGC 5194 and the smaller galaxy (M51B) is designated NGC 5195. M51 is located near the end star (Alkaid) in the Big Dipper's handle at an estimated distance of 31 million light years.
M51A and M51B have interacted gravitationally and this interaction has distorted the structure of the larger galaxy. From our point of view M51B, the smaller galaxy, is actually behind M51A and is receding from the larger galaxy. Some astronomers believe the smaller galaxy has possibly been captured by and is now in an elongated orbit around the larger M51A. The eventual result may be a merger of the two galaxies.