We explore the partitioning behavior of hydrogen between coexisting metal and silicate melts at conditions of the magma ocean and the current core–mantle boundary with the help of density functional theory molecular dynamics. We perform simulations with the two-phase and thermodynamic integration methods. We find that hydrogen is weakly siderophile at low pressure (20 GPa and 2,500 K), and becomes much more strongly so with pressure, suggesting that hydrogen is transported to the core in a significant amount during core segregation and is stable there. Based on our results, the core likely contains ~1 wt% H, assuming single-stage formation and equilibration at 40 GPa. Our two-phase simulations further suggest that silicon is entrained in th...