This study examined the association between long working hours and cognitive function in middle age. Data were collected in 1997-1999 (baseline) and 2002-2004 (follow-up) from a prospective study of 2,214 British civil servants who were in full-time employment at baseline and had data on cognitive tests and covariates. A battery of cognitive tests (short-term memory, Alice Heim 4-I, Mill Hill vocabulary, phonemic fluency, and semantic fluency) were measured at baseline and at follow-up. Compared with working 40 hours per week at most, working more than 55 hours per week was associated with lower scores in the vocabulary test at both baseline and follow-up. Long working hours also predicted decline in performance on the reasoning test (Alice Heim 4-I). Similar results were obtained by using working hours as a continuous variable; the associations between working hours and cognitive function were robust to adjustments for several potential confounding factors including age, sex, marital status, education, occupation, income, physical diseases, psychosocial factors, sleep disturbances, and health risk behaviors. This study shows that long working hours may have a negative effect on cognitive performance in middle age.