Illicium verum Hook. f. (star anise) is a highly important plant in terms of both its edible and medicinal properties and its economic value. The suitable habitat for star anise may undergo alterations in response to climate changes and human activities, which in turn might impact its quality. To ensure the future introduction and protection of star anise, it is crucial to analyze the impacts of climate change on the potential distribution of the species. The approach presented in this study integrates the MaxEnt model and chemical composition analysis to assess the potential distribution patterns of star anise in response to climate change and evaluate the impact of environmental variables on its quality. The results revealed that the soil pH, mean temperature of the coldest quarter, mean diurnal range, precipitation of the warmest quarter and annual precipitation were the main factors affecting the current distribution of I. verum. The current area of suitable habitat is approximately 17.6 × 104 km2, accounting for 74% of the total area of Guangxi Province. Under the future climate scenarios, the overall pattern of the potential distribution range shifted northwards, and the SSP3126 scenario showed the most significant increase in the area. By utilizing comprehensive 2D chromatography technologies, 111 volatile compounds present in the 61 batches of star anise were identified. Further analysis via chemometric methods revealed that the components β-bisabolene, caryophyllene, 4-methoxyphenylacetone, cis-β-farnesene, anethole and linalool could serve as potential markers for distinguishing the quality of star anise from different geographical origins. Finally, a stepwise regression model between chemical compositions and environmental variables was established, and based on this, a quality zoning map was subsequently plotted. This study provides valuable scientific insights for resource conservation, planting site selection and quality control for star anise.