Scientists have donned their Sherlock Holmes caps to solve a mystery that's been running for decades – the origins of a huge, layered expanse of CO2 ice and water ice at the south pole of Mars, and its link to the CO2 in the Martian atmosphere.

One leading hypothesis is that these layers were packed on top of each other as the axis of Mars tilts towards and away from the Sun, and simulation models published in a new study back up that idea.

The ice cap in question is around a kilometre (two-thirds of a mile) deep, and is thought to hold as much CO2 as there is in the entirety of the Martian atmosphere today, and a combination of factors have produced this unusual layered pattern.

"Usually, when you run a model, you don't expect the results to match so closely to what you observe," says Peter Buhler, a planetary scientist at NASA's Jet Propulsion Laboratory.

"But the thickness of the layers, as determined by the model, matches beautifully with radar measurements from orbiting satellites."

What makes the ice cap at the south pole so strange is that it shouldn't really be there – water ice is more thermally stable and darker than CO2 ice, so scientists would expect CO2 ice to destabilise when trapped under water ice.

Three factors have stopped that from happening, according to the new model: the changing tilt of Mars as it orbits the Sun, the differences in the way that these two types of ice reflect sunlight, and the change in atmospheric pressure that happens when CO2 ice turns into a gas.

The 'wobbles' of Mars on its rotational access would change the amount of sunlight reaching the south pole – forming CO2 ice during some periods and subliming it (transitioning it from a solid to a gas) during other periods.

During the periods of ice formation, water ice would've been trapped alongside the CO2. As sublimation happened, this more stable ice would have remained behind, forming the layers now present at the south pole of Mars.

As time has gone on, the changing climate of the Red Planet has meant that not all the CO2 ice was sublimed each time, stacking up successive layers of CO2 ice and water ice. The models show this process changing the atmospheric pressure – from between one-quarter to two times the level that it is today – just as Leighton and Murray predicted in the 1960s.

This has been going on for some 510,000 years, the scientists suggest – since the last period of extreme solar sunlight, when all the CO2 would have been sublimed into the Martian atmosphere.

Being more confident in the story behind the ice cap at the south pole of Mars means researchers can potentially understand more about the long-term history of the planet – peering back billions of years.

"Our determination of the history of Mars's large pressure swings is fundamental to understanding the evolution of Mars's climate, including the history of liquid water stability and habitability near Mars's surface," says Buhler.

The research has been published in Nature Astronomy.