The observation of gullies on Mars indicates the presence of liquid water near the surface in recent times, which is difficult to reconcile with the current cold climate. Gullies have been proposed to form through surface runoff from subsurface aquifers or through melting of near-surface ice under warmer conditions. But these gullies are observed to occur preferentially in cold mid-latitudes, where the presence of liquid water is less likely, and on isolated surfaces where groundwater seepage would not be expected, making both potential explanations unsatisfactory. Here I show that gullies can form by the melting of water-rich snow that has been transported from the poles to mid-latitudes during periods of high obliquity within the past 105 to 106 years (refs 5, 6). Melting within this snow can generate sufficient water to erode gullies in about 5,000 years. My proposed model for gully formation is consistent with the age and location of the gullies, and it explains the occurrence of liquid water in the cold mid-latitudes as well as on isolated surfaces. Remnants of the snowpacks are still present on mid-latitude, pole-facing slopes, and the recent or current occurrence of liquid water within them provides a potential abode for life.