In this paper, we present near-infrared transit spectroscopy of XO-2b obtained with HST NICMOS. Particular attention is given to systematic effects in order to interpret features in the final spectrum. Fortunately, the XO-2 binary companion is close enough to appear simultaneously in the NICMOS field of view. The companion star does not have a transiting hot Jupiter, and is an ideal comparison star because its brightness and spectrum are almost identical to the star that hosts the transiting planet. This is the first time that a such a reference star is present in NICMOS exoplanet spectroscopic observations (a second star was present in the field of view of HD189733 [@Swain2008], but was too faint to be useful). The analysis presented in this paper is systematically applied to both stars in the same way. This is a unique opportunity in NICMOS exoplanet spectroscopic studies to provide clues to the interpretation of results as molecular signatures of the planet’s atmosphere or instrumental effects.

The observations are described in Section \[sec:Observations\], and the data reduction in Section \[sec:Data reduction\]. We present the white-light photometric analysis in Section \[sec:White-light photometry\]. The spectral analysis is detailed in Section \[sec:Spectrum\], and the results are discussed in 