A method of in situ X-ray diffraction at Spring-8 (Japan) was used to analyze simultaneously the hydrogen incorporation into Fe and Fe3C, as well as to measure the relative stability of carbides, nitrides, sulfides, and hydrides of iron at pressures of 6–20 GPa and temperatures up to 1600 K. The following stability sequence of individual iron compounds was established in the studied pressure and temperature interval: FeS > FeN > FeC > FeH > Fe. A change in the unit-cell volume as compared to the known equations of state was used to estimate the hydrogen contents in carbide Fe3C and hydride FeHx. Data on hydride correspond to stoichiometry with x ≈ 1. Unlike iron sulfides and silicides, the solubility of hydrogen in Fe3C seemed to be negligibly low—within measurement error. Extrapolating obtained data to pressures of the Earth’s core indicates that carbon and hydrogen are mutually incpompatible in the iron–nickel core, while nitrogen easily substitutes carbon and may be an important component of the inner core in the light of the recent models assuming the predominance of iron carbide in its composition.