The compressive stress distribution below the specimen surface of a nanocrystalline medium carbon steel was investigated nondestructively by using high-energy X-rays from a synchrotron radiation source, SPring-8 (Super Photon ring-8 GeV) in the Japan Synchrotron Radiation Research Institute. A medium carbon steel plate was shot-peened with fine cast iron particles of the size of 50 μm. By using the monochromatic X-ray beam with three energy levels of 10, 30 and 72 keV, the stress values at the arbitrary depth were measured by the constant penetration depth method. The stress was calculated from the slope of the sin2ψ diagram. Measured stress corresponds to the weighted average associated with the attenuation of the X-rays in the material. The real stress distribution was estimated by using the optimization technique. The stress distribution was assumed by the third order polynomial in the near surface layer and the second order polynomial. The coefficients of the polynomials were determined by the conjugate gradient iteration. The predicted stress distribution agreed well with that measured by the conventional surface removal method.