We present high-resolution spectroscopy of gaseous CO absorption in the fundamental ro-vibrational band toward the heavily obscured active galactic nucleus (AGN) IRAS 08572+3915. We have detected absorption lines up to highly excited rotational levels (J<=17). The velocity profiles reveal three distinct components, the strongest and broadest (delta_v > 200 km s-1) of which is due to blueshifted (-160 km s-1) gas at a temperature of ~ 270 K absorbing at velocities as high as -400 km s-1. A much weaker but even warmer (~ 700 K) component, which is highly redshifted (+100 km s-1), is also detected, in addition to a cold (~ 20 K) component centered at the systemic velocity of the galaxy. On the assumption of local thermodynamic equilibrium, the column density of CO in the 270 K component is NCO ~ 4.5 x 10^18 cm-2, which in fully molecular gas corresponds to a H2 column density of NH2 ~ 2.5 x 10^22 cm-2. The thermal excitation of CO up to the observed high rotational levels requires a density greater than nc(H2) > 2 x 10^7 cm-3, implying that the thickness of the warm absorbing layer is extremely small (delta_d < 4 x 10-2 pc) even if it is highly clumped. The large column densities and high radial velocities associated with these warm components, as well as their temperatures, indicate that they originate in molecular clouds near the central engine of the AGN.