X-ray photoelectron spectroscopy (XPS) is a surface analysis technique for the nondestructive identification of elemental species and chemical states of solid samples, and the measured spectra are affected by not only sample-specific information but also factors dependent on the measurement environment. This feature makes it difficult to analyze the data for the chemical state identification of mixed samples when referring to the data measured with different models or in different environments. In a previous study, Bayesian inference was successfully applied to the analysis of XPS narrow-scan spectra, but the challenge was to apply Bayesian inference to XPS spectra of samples that are nonuniform in the depth direction. We propose a method to infer the layer structure of a sample from XPS spectra by incorporating Bayesian inference into the simulation of electron spectra for surface analysis (SESSA). SESSA can simulate XPS spectra of samples with specified composition and microstructure, and is already in use as a simulator with highly reproducible results. By utilizing the proposed method, one can estimate the layer structure of a sample from XPS data on the basis of the posterior probability distribution. In a typical XPS measurement, wide-scan data are acquired to qualitatively identify elemental species, and narrow-scan data are acquired to the estimate detailed composition and chemical state information of a sample. In this study, we have shown that given wide-scan or narrow-scan data without angle resolution, Bayesian inference can be applied to quantitatively analyze the layer structure information.