Current estimates of the budget and distribution of water in the Earth have large uncertainties, most of which come from the lack of information about the deep Earth. Recent studies suggest that the Earth could have gained a considerable amount of water during the early stages of Earth's evolution from the hydrogen-rich solar nebula, and that a large amount of the water in the Earth may have partitioned into the core. Here, we calculate the partitioning of water between iron and silicate melts at 20-135 gigapascals and 2800-5000 kelvin, using ab initio molecular dynamics and thermodynamic integration techniques. Our results indicate a siderophile nature of water at core-mantle differentiation and core-mantle boundary conditions, which can be weakened with increasing temperature; nevertheless, we find that water always partitions strongly into the iron liquid at both reducing and oxidising conditions. The siderophile nature of water is also verified by an empirical-counting method showing the distribution of hydrogen in an equilibrated iron and silicate melt. We therefore conclude that the Earth's core may act as a large reservoir containing most of the Earth's water. In addition to constraining accretion models and water distribution, the findings may partially account for the mismatch between mineral physics and seismic observations in the Earth's core.