Large fossil water deposits depend on the climate having been different in the geologically recent past. The significant dryland aquifers in the world are not that old. There are broadly two types.
The first type is like the Nubian Sandstone aquifer across the North Sahara, primarily in Libya. The water in this aquifer comes from the Neolithic Subpluvial, also called the 'Green Sahara'. This was a time period from about 7000 BC to 5000 BC. At this time, the Sahara was much smaller and the North Sahara area got signficant winter rainfall, much like the climate farther north in Tunisia or Greece. Since the land is relatively flat, it did not rapidly flow away, but tended to form chains of lakes. These lakes allowed much groundwater to seep into the bedrock. Eventually it pooled underground where the rock layers stopped it and is still here to the present...at least until thirsty humans pump it all out.
The second type is like the Ogalla reservoir in the High Plains. This isn't strictly a desert, but it is semi-arid and doesn't get much rain. The massive reservoir is deposited from water seeping from the many rivers coming off the Rockies. The Missouri, Plattes, Canadian, Arkansas and more rivers come down from Montana to Colorado and flow across the plains to the Mississippi. Their flow rate isn't that high, but it is enough to recharge the aquifer. So in this case, the water level is actively recharging, unlike the Nubian Sandstone.
If you are talking about a very dry desert ringed with mountains, then one of the best examples would be the Tarim basin in China. It too has a large aquifer underneath it, of the Ogalla type. Ringed by high mountains like the Kunlun and Tien Shan, spring snow melts brings water into the basin every year. The water doesn't get very far, but can still be used for irrigation at famous Silk Road outposts like Kashgar or Khotan. What does make it to the desert sands disspaears, partly through evaporation, and partly through seepage into this aquifer. On the other hand, it is worth noting the fact that this particular aquifer is only being found today because it is at depth where where you need an oil rig to get it out. So it wasn't exactly usable to the ancients, who needed to depend on meltwater.