Background: Primary headaches have a high prevalence among university students. Lifestyle has an important role in the prevention and management of these headaches. Among lifestyle factors, data on the association between physical activity and primary headaches are scarce and conflicting.Aim: To examine the association between physical activity and primary headaches among a large population of university students.Methods: Totally, 83,463 university students from 28 provinces of Iran were included in the current cross-sectional study. Data on physical activity, dietary intakes, and demographic characteristics were collected using pre-tested questionnaires. Primary headaches were determined according to the International Classification of Headache Disorders-3 (ICHD-3) criteria.Results: Mean age of university students was 21.50 ± 4.01, and 54.7% were female. Primary headaches were prevalent among 9% of students. A significant inverse association was seen between physical activity and primary headaches in the whole population (OR: 0.66, 95% CI: 0.62-0.71). Such an inverse association was also observed after taking potential confounders into account; such that students who were physically active had 21% lower odds of primary headaches compared with those who were physically inactive (OR: 0.79, 95% CI: 0.72-0.87). Also, physical activity was associated with reduced odds of primary headaches in male and female students (Males; OR: 0.70, 95% CI: 0.60-0.82, females; OR: 0.84, 95% CI: 0.75-0.94) as well as those students with normal-weight (OR: 0.79, 95% CI: 0.71-0.87), overweight, or obesity (OR: 0.80, 95% CI: 0.66-0.96).Conclusion: Our findings support the protective association between physical activity and primary headaches.