Context. Low-mass stars are currently the best targets when searching for rocky planets in the habitable zone of their host star. Over the last 13 years, precise radial velocities measured with the HARPS spectrograph have identified over a dozen super-Earths and Earth-mass planets (msin i ≤ 10 M ⊕ ) around M dwarfs, with a well-understood selection function. This well-defined sample provides information on their frequency of occurrence and on the distribution of their orbital parameters, and therefore already constrains our understanding of planetary formation. The subset of these low-mass planets that were found within the habitable zone of their host star also provide prized targets for future searches of atmospheric biomarkers. Aims. We are working to extend this planetary sample to lower masses and longer periods through dense and long-term monitoring of the radial velocity of a small M dwarf sample. Methods. We obtained large numbers of HARPS spectra for the M dwarfs GJ 3138, GJ 3323, GJ 273, GJ 628, and GJ 3293, from which we derived radial velocities (RVs) and spectroscopic activity indicators. We searched for variabilities, periodicities, Keplerian modulations, and correlations, and attribute the radial-velocity variations to combinations of planetary companions and stellar activity. Results. We detect 12 planets, 9 of which are new with masses ranging from 1.17 to 10.5 M ⊕ . These planets have relatively short orbital periods (P<40 d), except for two that have periods of 217.6 and 257.8 days. Among these systems, GJ 273 harbor two planets with masses close to the Earth's. With a distance of only 3.8 parsec, GJ 273 is the second nearest known planetary system -after Proxima Centauri -with a planet orbiting the circumstellar habitable zone.