---
abstract: 'Spectroscopy during planetary transits is a powerful tool to probe exoplanet atmospheres. We present the near-infrared transit spectroscopy of XO-2b obtained with HST NICMOS. Uniquely for NICMOS transit spectroscopy, a companion star of similar properties to XO-2 is present in the field of view. We derive improved star and planet parameters through a photometric white-light analysis. We show a clear correlation of the spectrum noise with instrumental parameters, in particular the angle of the spectral trace on the detector. An MCMC method using a decorrelation from instrumental parameters is used to extract the planetary spectrum. Spectra derived independently from each of the 3 visits have a RMS of 430, 510, and 1000 ppm respectively. The same analysis is performed on the companion star after numerical injection of a transit with a depth constant at all wavelengths. The extracted spectra exhibit residuals of similar amplitude as for XO-2, which represent the level of remaining NICMOS systematics. This shows that extracting planetary spectra is at the limit of NICMOS’ capability. We derive a spectrum for the planet XO-2b using the companion star as a reference. [The derived spectrum can be represented by a theoretical model including atmospheric water vapor or 