Objective: To investigate the association between serum 25-hydroxyvitamin D [25(OH)D] level and history of community-acquired pneumonia (CAP). Patients and Methods We identified 16,975 individuals (≥17 years) from the third National Health and Nutrition Examination Survey (NHANES III) with documented 25(OH)D levels. To investigate the association of 25(OH)D with history of CAP in these participants, we developed a multivariable logistic regression model, adjusting for demographic factors (age, sex, race, poverty-to-income ratio, and geographic location), clinical data (body mass index, smoking status, asthma, chronic obstructive pulmonary disease, congestive heart failure, diabetes mellitus, stroke, chronic kidney disease, neutropenia, and alcohol consumption), and season. Locally weighted scatterplot smoothing (LOWESS) was used to depict the relationship between increasing 25(OH)D levels and the cumulative frequency of CAP in the study cohort. Results: The median [interquartile range (IQR)] serum 25(OH)D level was 24 (IQR 18–32) ng/mL. 2.1% [95% confidence interval (CI): 1.9–2.3] of participants reported experiencing a CAP within one year of their participation in the national survey. After adjusting for demographic factors, clinical data, and season, 25(OH)D levels <30 ng/mL were associated with 56% higher odds of CAP [odds ratio 1.56; 95% confidence interval: 1.17–2.07] compared to levels ≥30 ng/mL. LOWESS analysis revealed a near linear relationship between vitamin D status and the cumulative frequency of CAP up to 25(OH)D levels around 30 ng/mL. Conclusion: Among 16,975 participants in NHANES III, 25(OH)D levels were inversely associated with history of CAP. Randomized controlled trials are warranted to determine the effect of optimizing vitamin D status on the risk of CAP