We develop a method of the ab initio calculation for the core-level x-ray photoemission spectroscopy ͑XPS͒. By calculating one-electron states in the presence of core-hole potential, excited states are constructed by distributing electrons on these one-electron states. The overlap integrals between the excited states and the ground state are evaluated by using the wave functions with and without the core-hole potential, and finally the XPS spectra are obtained. Implementing the procedure, we obtain the spin-resolved 3s-core XPS spectra in ferromagnetic iron without any adjustable parameters, in good agreement with the experiment. The spectral shapes are quite different for different spin channels. We explain the behavior in terms of the difference in the one-electron states screening the core-hole potential.