Context : Aims : The aim of the project is to find the stars nearest to the Sun and to contribute to the completion of the stellar and substellar census of the solar neighbourhood . Methods : We identified a new late-M dwarf within 5 pc , looking for high proper motion sources in the 2MASS–WISE cross-match . We collected astrometric and photometric data available from public large-scale surveys . We complemented this information with low-resolution ( R \sim 500 ) optical ( 600–1000 nm ) and near-infrared ( 900–2500 nm ) spectroscopy with instrumentation on the European Southern Observatory New Technology Telescope to confirm the nature of our candidate . We also present a high-quality medium-resolution VLT/X-shooter spectrum covering the 400 to 2500 nm wavelength range . Results : We classify this new neighbour as an M7.0 \pm 0.5 dwarf using spectral templates from the Sloan Digital Sky Survey and spectral indices . Lithium absorption at 670.8 nm is not detected in the X-shooter spectrum , indicating that the M7 dwarf is older than 600 Myr and more massive than 0.06 M _ { \odot } . We also derive a trigonometric distance of 4.4 ^ { +0.5 } _ { -0.4 } pc , in agreement with the spectroscopic distance estimate , making 2MASS J154043.42 - 510135.7 ( 2M1540 ) the nearest M7 dwarf to the Sun . This trigonometric distance is somewhat closer than the \sim 6 pc distance reported by the ALLWISE team , who independently identified this object recently . This discovery represents an increase of 25 % in the number of M7–M8 dwarfs already known at distances closer than 8 pc from our Sun . We derive a density of \rho = 1.9 \pm 0.9 \times 10 ^ { -3 } pc ^ { -3 } for M7 dwarfs in the 8 pc volume , a value similar to those quoted in the literature . Conclusions : This new ultracool dwarf is among the 50 nearest systems to the Sun , demonstrating that our current knowledge of the stellar census within the 5 pc sample remains incomplete . 2M1540 represents a unique opportunity to search for extrasolar planets around ultracool dwarfs due to its proximity and brightness .