The ability of a celestial body to retain an atmosphere depends primarily on its gravitational strength (related to mass) and the temperature of the gas (related to molecular velocity). If the escape velocity is less than the thermal velocity of gas molecules, the atmosphere escapes.