  We report the results of a deep XMM-Newton observation of the radio-faint
$\gamma$-ray pulsar J1741-2054 and its nebula together with the analysis of 5
years of Fermi LAT data. The X-ray spectrum of the pulsar is consistent with an
absorbed power law plus a blackbody, originating at least partly from the
neutron star cooling. The nebular emission is consistent with that of a
synchrotron pulsar wind nebula, with hints of spatial spectral variation. We
extended the available Fermi LAT ephemeris and folded the $\gamma$-ray and
X-ray data. We detected X-ray pulsations from the neutron star: both the
thermal and non-thermal components are about 35-40% pulsed, with phase-aligned
maxima. A sinusoid fits the thermal folded profile well. A 10-bin
phase-resolved analysis shows softening of the non-thermal spectrum during the
on-pulse phases. The radio, X-ray and $\gamma$-ray light curves are
single-peaked, not phase-aligned, with the X-ray peak trailing the $\gamma$-ray
peak by over half a rotation. Spectral considerations suggest that the most
probable pulsar distance is in the 0.3-1.0 kpc range.
