The underlying wettability alteration mechanism responsible for enhanced oil recovery (EOR) in carbonate reservoir is a long-standing issue for which no consensus has been reached yet. In this paper, we report extensive quantum molecular dynamics simulations to reveal the roles of wettability modifiers Na + , Cl-, Ca 2+ , Mg 2+ , and SO 4 2ions in EOR. Characterizing wettability by contact angle using the work-of-adhesion approach, we find that the calcite surface is strongly hydrophilic, with the first two wetting layers hindering all ions from reaching the surface, i.e. ions are only "proximally adsorbed". Na + and Clions settle closer to the surface and actually disturb the interfacial water structure of the first two wetting layers, which renders the surface less water-wet and thus inhibits oil recovery, as observed. Ca 2+ , Mg 2+ and SO 4 2ions, on the other hand, settle farther from the surface and retain the interfacial water structure, but render the surface more water-wet by modifying the effective charge on the surface, which enhances oil recovery, as observed. The impact of the ions is more pronounced at high temperatures as proximal adsorption is enhanced. In addition to theory, we report new core flooding measurements that corroborate the theoretical results. The present study brings new insights into the wettability alteration mechanism in EOR at the atomic scale.