Inflammation plays a part in the etiology of dementia. Whether this is the primary pathogenesis, or a secondary reaction is unclear. We postulate that since systemic infection can provoke the enhanced synthesis of inflammatory mediators in the brain, such diseases may promote the onset of dementia. We carried out a nested case-control study using the General Practice Research Database. Cases were patients with incident dementia, and controls without such a diagnosis. Infectious episodes in the four years preceding diagnosis were counted using diagnostic codes, or prescription codes for anti-infective drugs. We considered age, sex, smoking, diabetes mellitus, and frequency of consultation as potential confounders. There were 9954 valid cases, and 9374 valid controls. Cases were on average older, more likely to be female, to smoke and to have diabetes, than the controls. There was an increased risk of diagnosis of dementia in those patients older than 84 with infections (OR for 2 or more infections compared with 0 or 1 = 1.4, 95% CI 1.2 to 1.7). Smoking and diabetes mellitus were also shown to markedly increase the risk of diagnosis of dementia. We have shown a positive association between episodes of infection and increased likelihood of diagnosis of dementia in the very elderly. Smoking and diabetes mellitus are associated with onset of dementia in the elderly. The evidence from this study may represent cause and effect, since there is a credible biologic explanation.