Molecular dynamics calculations have been used to determine the structure of phosphatidylinositol 4,5 bisphosphate (PIP2) at the quantum level and to quantify the propensity for PIP2 to bind two physiologically relevant divalent cations, Mg2+ and Ca2+. We performed a geometry optimization at the Hartree-Fock 6-31+G(d) level of theory in vacuum and with a polarized continuum dielectric to determine the conformation of the phospholipid headgroup in the presence of water and its partial charge distribution. The angle between the headgroup and the acyl chains is nearly perpendicular, suggesting that in the absence of other interactions, the inositol ring would lie flat along the cytoplasmic surface of the plasma membrane. Next, we employed hybrid quantum mechanics / molecular mechanics (QM/MM) simulations to investigate the protonation state of PIP2 and its interactions with magnesium or calcium. We test the hypothesis suggested by prior experiments that binding of magnesium to PIP2 is mediated by a water molecule that is absent when calcium binds. These results may explain the selective ability of calcium to induce the formation of PIP2 clusters and phase separation from other lipids.