In this paper we analyse five observations of the BL Lac object AO 0235+16 performed with the Chandra and XMM-Newton satellites during the years 2000-2005. In the February 2002 observation the source is found in a bright state and presents a steep X-ray spectrum, while in all the other epochs it is faint and the spectrum is hard. The soft X-ray spectrum appears to be strongly absorbed, likely by the intervening system at z=0.524, which also absorbs the optical-UV radiation. We find that models that consider spectral curvature are superior to single power law ones in fitting the X-ray spectrum. In particular, we favour a double power law model, which agrees with the assumption of a superposition of two different components in the X-ray domain. Both in the Chandra and in one of the XMM-Newton observations, a tentative detection of the redshifted Fe Kalpha emission line may suggest its origin from the inner part of an accretion disc. Thermal emission from this accretion disc might explain the UV-soft-X-ray bump that appears in the spectral energy distributions, when the X-ray spectra are complemented with the optical-UV data from the Optical Monitor onboard XMM-Newton. More likely, the bump can be interpreted in terms of an additional synchrotron component emitted from an inner region of the jet with respect to that where the lower-energy emission comes from. An inspection of the X-ray light curves reveals that intraday variability occurs only when the source is in a bright state.