The Persians had a system of freezing water in the cooler months and storing it for long periods, even throughout the summer. The method used involves evaporative cooling and night sky radiation (more on this linked below) to freeze water even at ambient temperatures above freezing.
These storage buildings are called yakhchal (meaning ice-pit). Several of these are still standing, particularly in Iran. They were made from thick mud brick in a sort of conical/domed shape with an opening at the top and dug into the ground at the bottom. The ice would freeze at the bottom, and the dome would be covered with thatching during the day which was removed at night. This helped insulate the cool air inside the building during the day, and let the heat radiate away at night.
When you look at the engineering behind these yakhchal and other related buildings like windcatchers, it's apparent that the Persians were masters at dissipating heat. The channels of water that fed the yakhchal and the buildings themselves were walled to shield the water from direct sunlight, and the buildings were placed on the outskirts to reduce radiant heat from the city from interfering in the process.
If you're interested in more reading, this website has a great breakdown, and the sources used are in-depth and linked at the bottom of the article in pdf form.
If you are interested in the actual mathematics on how this functions, the same writer did a follow up article on night sky radiant cooling here.
Warning, there's a lot of math involved. The basic idea is that the earth stays relatively the same temperature. So all energy we receive during the day escapes again (unless it gets trapped by greenhouse gases). By insulating something during the day and removing that insulation at night, you maximize your cooling potential.
For convenience sake, here are the sources listed in the article:
“Historical Ice Houses: Remarkable Example of Iranian Cultural Heritage”, Amirkhani ARYAN, Okhovat HANIE, Pourjafar Mohammad REZA, Zamani EHSAN (The article has a direct link to a downloadable file)
on top of what u/stylepointseso mentioned, Iran isn't all desert, and has many temperate and even cold mountainous areas. Many of these areas receive substantial amounts of snow in the winter