Background: Vitamin D is important for bone, cartilage and muscle function but there are few studies on its association with joint pain. Objective: To investigate whether serum vitamin D predicts change in knee and hip pain in older adults. Methods: Longitudinal population-based cohort study of randomly selected older adults (n=769) aged 50-80 years (mean 62 years); 50% were male. Serum 25-hydroxyvitamin D (25-OHD) was assessed at baseline by radioimmunoassay, and pain at baseline, 2.6 and/or 5 years using the Western Ontario and McMaster University Osteoarthritis Index (WOMAC) questionnaire. We used linear regression with adjustment for age, sex, body mass index and season, then further adjusted for potential structural mechanisms (radiographic osteoarthritis, bone marrow lesions, chondral defects and muscle strength). Results: Mean total knee WOMAC score was 3.2 (range 0-39). 4.2% of participants had moderate vitamin D deficiency at baseline (25-OHD 12.5-25 nmol/l). 25-OHD <25 nmol/l predicted change in knee pain (using total WOMAC score) over 5 years (β=2.41, p=0.002) with a similar effect size for hip pain over 2.4 years (β=2.20, p=0.083). Results were consistent within pain subscales, and the association was independent of demographic, anthropometric and structural covariates. No association was present when 25-OHD was analysed as a continuous measure. Conclusions: Moderate vitamin D deficiency independently predicts incident, or worsening of, knee pain over 5 years and, possibly, hip pain over 2.4 years. Therefore correcting moderate vitamin deficiency may attenuate worsening of knee or hip pain in elderly people but giving supplements to those with a higher 25-OHD level is unlikely to be effective.