Context: Around 30 per cent of the observed exoplanets that orbit M dwarf stars are gas giants that are more massive than Jupiter. These planets are prime candidates for formation by disc instability. Aims: We want to determine the conditions for disc fragmentation around M dwarfs and the properties of the planets that are formed by disc instability. Methods: We performed hydrodynamic simulations of M dwarf protostellar discs in order to determine the minimum disc mass required for gravitational fragmentation to occur. Different stellar masses, disc radii, and metallicities were considered. The mass of each protostellar disc was steadily increased until the disc fragmented and a protoplanet was formed. Results: We find that a disc-to-star mass ratio between $sim 0.3$ and $sim 0.6$ is required for fragmentation to happen. The minimum mass at which a disc fragments increases with the stellar mass and the disc size. Metallicity does not significantly affect the minimum disc fragmentation mass but high metallicity may suppress fragmentation. Protoplanets form quickly (within a few thousand years) at distances around $sim50$ AU from the host star, and they are initially very hot; their centres have temperatures similar to the ones expected at the accretion shocks around planets formed by core accretion (up to 12,000K). The final properties of these planets (e.g. mass and orbital radius) are determined through long-term disc-planet or planet-planet interactions. Conclusions: Disc instability is a plausible way to form gas giant planets around M dwarfs provided that discs have at least 30% the mass of their host stars during the initial stages of their formation. Future observations of massive M dwarf discs or planets around very young M dwarfs are required to establish the importance of disc instability for planet formation around low-mass stars.