Forty-five years ago Gerhard Herzberg became the first person to observe lines of the infrared rotation–vibration bands of molecular hydrogen; 20 years ago astronomers first found some of these lines in the interstellar medium. Examples are given of astrophysical environments in which H2 has been detected, with emphasis on their growing importance to astronomy. The rotation–vibration spectrum has been observed in emission following both collisional and radiative excitation processes. Recent detections of absorption by cold interstellar molecular hydrogen, both in the gaseous and the solid states, have expanded knowledge of physical properties of molecular clouds and the physical and chemical processes occurring within them.