Sweet orange ‘Newhall’ peels (SOPs) are abundant in flavonoids, making them increasingly popular in the realms of nutrition, food, and medicine. However, there is still much unknown about flavonoid components in SOPs and the molecular mechanism of flavonoid biosynthesis when subjected to magnesium stress. The previous experiment conducted by the research group found that the total flavonoid content of Magnesium deficiency (MD) was higher than Magnesium sufficiency (MS) in SOPs. In order to study the metabolic pathway of flavonoids under magnesium stress, an integrative analysis of the metabolome and transcriptome was performed in SOPs at different developmental stages, comparing MS and MD. A comprehensive analysis revealed the identification of 1,533 secondary metabolites in SOPs. Among them, 740 flavonoids were classified into eight categories, with flavones identified as the dominant flavonoid component. The influence of magnesium stress on flavonoid composition was evaluated using a combination of heat map and volcanic map, which indicated significant variations between MS and MD varieties at different growth stages. The transcriptome detected 17,897 differential genes that were significantly enriched in flavonoid pathways. Further analysis was performed using Weighted gene correlation network analysis (WGCNA) in conjunction with flavonoid metabolism profiling and transcriptome analysis to identify six hub structural genes and ten hub transcription factor genes that play a crucial role in regulating flavonoid biosynthesis from yellow and blue modules. The correlation heatmap and Canonical Correspondence Analysis (CCA) results showed that CitCHS had a significant impact on the synthesis of flavones and other flavonoids in SOPs, as it was the backbone gene in the flavonoid biosynthesis pathway. The qPCR results further validated the accuracy of transcriptome data and the reliability of candidate genes. Overall, these results shed light on the composition of flavonoid compounds in SOPs and highlight the changes in flavonoid metabolism that occur under magnesium stress. This research provides valuable insights for improving the cultivation of high-flavonoid plants and enhancing our understanding of the molecular mechanisms underlying flavonoid biosynthesis.