  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
M31. 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^{\circ}-80^{\circ}$. 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 $\times10^{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}}$.
