The interaction between a carboxylate anion (deprotonated propanoic acid) and the divalent Mg(2+), Ca(2+), Sr(2+), Ba(2+) metal ions is studied via ab initio molecular dynamics. The main focus of the study is the selectivity of the carboxylate-metal ion interaction in aqueous solution. The interaction is modeled by explicitly accounting for the solvent molecules on a DFT level. The hydration energies of the metal ions along with their diffusion and mobility coefficients are determined and a trend correlated with their ionic radius is found. Subsequently, a series of 16 constrained molecular dynamics simulations for every ion is performed, and the interaction free energy is obtained from thermodynamic integration of the forces between the metal ion and the carboxylate ion. The results indicate that the magnesium ion interacts most strongly with the carboxylate, followed by calcium, strontium, and barium. Because the interaction free energy is not enough to explain the selectivity of the reaction observed experimentally, more detailed analysis is performed on the simulation trajectories to understand the steric changes in the reaction complex during dissociation. The solvent dynamics appear to play an important role during the dissociation of the complex and also in the observed selectivity behavior of the divalent ions.