Aims. We report spectra of the overtone and fundamental bands of CO in the eruptive variable V838 Mon, which trace the recent evolution of the star and allow its ejecta to be characterized. Methods. The data were obtained at the United Kingdom Infrared Telescope on fourteen nights from 2002 January, shortly after the first outburst of the star, to 2006 April. Results. Although the near-infrared stellar spectrum superficially resembled a cool supergiant after both the first and third of its outbursts in 2002, its infrared "photosphere" at that time consisted of highly blueshifted gas that was moving outward from the original stellar surface. A spectrum obtained during the third outburst reveals a remarkable combination of emission and absorption in the CO first overtone bands. The most recent observations show a composite spectrum that includes a stellar-like photosphere at a temperature similar to that seen just after the initial outburst, but at a radial velocity redshifted by 15 km s −1 relative to the stellar velocity determined from SiO maser emission, suggesting that the atmosphere is now contracting. Three shell components, corresponding to expansion velocities of 15, 85, and 145 km s −1 , also are present, but absorption is seen at all expansion velocities out to 200 km s −1 . Weak absorption features of fundamental band lines of 13 CO have been detected. However, the large uncertainty in the value of 12 C/ 13 C does not constrain the evolutionary status of the progenitor.