Water cycling between Earths mantle and surface has previously been modelled and extrapolated to rocky exoplanets, but these studies neglected the host star. M-dwarf stars are more common than Sun-like stars and at least as likely to host temperate rocky planets (M-Earths). However, M dwarfs are active throughout their lifetimes; specifically, X-ray and extreme ultraviolet (XUV) radiation during their early evolution can cause rapid atmospheric loss on orbiting planets. The increasing bolometric flux reaching M-Earths leads to warmer, moister upper atmospheres, while XUV radiation can photodissociate water molecules and drive hydrogen and oxygen escape to space. Here, we present a coupled model of deep-water cycling and water loss to space on M-Earths to explore whether these planets can remain habitable despite their volatile evolution. We use a cycling parameterization accounting for the dependence of mantle degassing on seafloor pressure, the dependence of regassing on mantle temperature, and the effect of water on mantle viscosity and thermal evolution. We assume the M dwarfs XUV radiation decreases exponentially with time, and energy-limited water loss with 30% efficiency. We explore the effects of cycling and loss to space on planetary water inventories and water partitioning. Planet surfaces desiccated by loss can be rehydrated, provided there is sufficient water sequestered in the mantle to degas once loss rates diminish at later times. For a given water loss rate, the key parameter is the mantle overturn timescale at early times: if the mantle overturn timescale is longer than the loss timescale, then the planet is likely to keep some of its water.