Agriophyllum squarrosum (L.) Moq. (A. squarrosum), also known as sandrice, is an important medicinal plant widely distributed in dunes across all the deserts of China. Common garden trials have shown content variations in flavonoids among the ecotypes of sandrice, which correlated with temperature heterogeneity in situ. To further elucidate whether the accumulation of flavonoids was triggered by cold stress, we conducted a four-day ambient 4 °C low-temperature treatment on three ecotypes along with an in situ annual mean temperature gradient (Dulan (DL), Aerxiang (AEX), and Dengkou (DK)). Target metabolomics showed that 12 out of 14 flavonoids in sandrice were driven by cold stress. Among them, several flavonoids were significantly up-regulated, such as naringenin and naringenin chalcone in all three ecotypes; isorhamnetin, quercetin, dihydroquercetin, and kaempferol in DL and AEX; and astragalin in DK. They were accompanied by 19 structural genes of flavonoid synthesis and 33 transcription factors were markedly triggered by cold stress in sandrice. The upstream genes, AsqAEX006535−CHS, AsqAEX016074−C4H, and AsqAEX004011−4CL, were highly correlated with the enrichment of naringenin, which could be fine-tuned by AsqAEX015868−bHLH62, AsqAEX001711−MYB12, and AsqAEX002220−MYB1R1. This study sheds light on how desert plants adapt to cold stress by relying on flavonoids, and also supports the precise development of sandrice for the medicinal industry.