We report the discovery with XMM–Newton of 3-s X-ray pulsations from 3XMM J004232.1+411314 , a dipping source that dominates the hard X-ray emission of M 31 . This finding unambiguously assesses the neutron star ( NS ) nature of the compact object . We also measured an orbital modulation of 4.15 h and a projected semi-axis at a _ { \mathrm { X } } \sin i = 0.6 lt-s , which implies a low-mass companion of about 0.2–0.3 M _ { \odot } assuming a NS of 1.5 M _ { \odot } and an orbital inclination i = 70 \degr –80 \degr . The barycentric orbit-corrected pulse period decreased by \sim 28 ms in about 16 yr , corresponding to an average spin-up rate of \dot { P } \sim - 6 \times 10 ^ { -11 } s s ^ { -1 } ; pulse period variations , probably caused to by X-ray luminosity changes , were observed on shorter time scales . We identify two possible scenarios for the source : a mildly magnetic NS with B _ { \mathrm { p } } \simeq few \times 10 ^ { 10 } G if the pulsar is far from its equilibrium period P _ { \mathrm { eq } } , and a relatively young highly magnetic NS with B _ { \mathrm { eq } } \simeq 10 ^ { 13 } G if spinning close to P _ { \mathrm { eq } } .