The abundant occurrence of calcium carbonate minerals in marine sediments and their high fluorine content suggests that fluorine is a good candidate for reconstructing paleoceanographic parameters. However, the potential of fluorine as a paleoproxy had hardly been explored, and fundamental insights into the behaviour of fluorine in biogenic carbonates and marine sediments is required. A first-principles modelling approach is used here to analyse the incorporation mechanisms of fluorine into crystalline calcium carbonates. We compute F incorporation into the CaCO3 lattice via a number of mechanisms, but concentrate on comparison of the energetics of the two easiest substitution mechanisms: replacing one oxygen atom within the carbonate group to form a (CO2F)− group as against a substitution involving replacement of the CO3 group by two fluorine ions to form a CaF2 defect. These incorporation mechanisms are fundamentally different from that of iodine into calcium carbonates, where a carbon atom is replaced. Our simulations suggest that the substitution of CO32- by F22- is the most favoured and that fluorine is preferentially incorporated into the three naturally-occurring polymorphs of calcium carbonate in the order vaterite ⪆ aragonite ≫ calcite. These results explain the previously-reported preponderance of fluorine in aragonite corals, and lend support to the use of F/Ca as a proxy for ocean pCO2.