  Li-based phosphates are paradigmatic materials for magnetoelectricity. By
means of first-principles calculations, we elucidate the microscopic origin of
spin anisotropy and of magnetoelectric effects in LiNiPO4. The comparison with
LiCoPO4 reveals that Co-d7 and Ni-d8 electronic clouds show distinct orbital
shapes, which in turn result in an opposite trend of the local spin anisotropy
with respect to the surrounding O6 cages. Due to magnetic anisotropy, the
Ni-based phosphate shows a peculiar "angled-cross" spin ground-state, which is
responsible for magnetoelectricity. In this respect, we show that, under a
magnetic field Hx, an electronic polarization Pz arises, with an estimated
linear magneto-electric coefficient in good agreement with experiments.
