Neutron diffraction is used to probe the (H,T) phase diagram of magnetoelectric (ME) LiNiPO4 for magnetic fields along the c axis. At zero field the Ni spins order in two antiferromagnetic phases. One has commensurate (C) structures and general ordering vectors k(C)=(0,0,0); the other one is incommensurate (IC) with k(IC)=(0,q,0). At low temperatures the C order collapses above mu H-0=12 T and adopts an IC structure with modulation vector parallel to k(IC). We show that C order is required for the ME effect and establish how electric polarization results from a field-induced reduction in the total magnetoelastic energy.