Background Depression, anxiety and physical function may be bi-directionally related. We aim to estimate the strength of the longitudinal associations between depression, anxiety and physical function. Methods Prospective cohort study of general practice attendees across Europe (N1/44757) assessed at baseline, 6, 12 and 24 months. Main outcome measures were Diagnostic and Statistical Manual of Mental Disorders-IV major depression, Patient Health Questionnaire anxiety and Short Form 12 physical function. Complete-case analyses using random coefficient models and logistic regression models were performed. Results Those with depression (β = -1.90, 95% CI -3.42 to -0.39), anxiety (β = -4.12, 95% CI -5.39 to -2.86) or depression and anxiety (β = -5.74, 95% CI -7.38 to -4.10) had lower levels of physical function at baseline and over time compared with no diagnosis after adjustment for potential confounders. Physical function increased over time, but the rate of increase was not different between the groups. When compared with depression, those with anxiety (β = -2.22, 95% CI -4.08 to -0.36) or depression and anxiety (β = -3.83, 95% CI -5.95 to -1.71) had significantly lower levels of physical function at baseline. Lower levels of physical function at baseline were associated with onset of depression (OR 1.83, 95% CI 1.08 to 3.10) but even stronger with anxiety (OR 2.79, 95% CI 1.52 to 5.12) or depression and anxiety (OR 5.05, 95% CI 2.55 to 9.99) during 24 months compared with no dysfunction, after adjustment for potential confounders. Conclusion It is essential to prevent lower levels of physical function as this is likely to lead to onset of depression and anxiety over time.