Experimental observations have suggested a role of infection in the etiology of neurodegenerative disease. In human studies, however, it is difficult to disentangle whether infection is a risk factor or rather a comorbidity or secondary event of neurodegenerative disease. To this end, we examined the risk of 3 most common neurodegenerative diseases in relation to previous inpatient or outpatient episodes of hospital-treated infections. We performed a nested case-control study based on several national registers in Sweden. Cases were individuals newly diagnosed with Alzheimer's disease (AD), Parkinson's disease (PD), or amyotrophic lateral sclerosis (ALS) during 1970 to 2016 in Sweden, identified from the National Patient Register. For each case, 5 controls individually matched to the case on sex and year of birth were randomly selected from the general population. Conditional logistic regression was used to estimate odds ratios (ORs) and 95% confidence intervals (CIs) with adjustment for potential confounders, including sex, year of birth, area of residence, educational attainment, family history of neurodegenerative disease, and Charlson comorbidity index. Infections experienced within 5 years before diagnosis of neurodegenerative disease were excluded to reduce the influence of surveillance bias and reverse causation. The analysis included 291,941 AD cases (median age at diagnosis: 76.2 years; male: 46.6%), 103,919 PD cases (74.3; 55.1%), and 10,161 ALS cases (69.3; 56.8%). A hospital-treated infection 5 or more years earlier was associated with an increased risk of AD (OR = 1.16, 95% CI: 1.15 to 1.18, P < 0.001) and PD (OR = 1.04, 95% CI: 1.02 to 1.06, P < 0.001). Similar results were observed for bacterial, viral, and other infections and among different sites of infection including gastrointestinal and genitourinary infections. Multiple infections before age 40 conveyed the greatest risk of AD (OR = 2.62, 95% CI: 2.52 to 2.72, P < 0.001) and PD (OR = 1.41, 95% CI: 1.29 to 1.53, P < 0.001). The associations were primarily due to AD and PD diagnosed before 60 years (OR = 1.93, 95% CI: 1.89 to 1.98 for AD, P < 0.001; OR = 1.29, 95% CI: 1.22 to 1.36 for PD, P < 0.001), whereas no association was found for those diagnosed at 60 years or older (OR = 1.00, 95% CI: 0.98 to 1.01 for AD, P = 0.508; OR = 1.01, 95% CI: 0.99 to 1.03 for PD, P = 0.382). No association was observed for ALS (OR = 0.97, 95% CI: 0.92 to 1.03, P = 0.384), regardless of age at diagnosis. Excluding infections experienced within 10 years before diagnosis of neurodegenerative disease confirmed these findings. Study limitations include the potential misclassification of hospital-treated infections and neurodegenerative diseases due to incomplete coverage of the National Patient Register, as well as the residual confounding from unmeasured risk or protective factors for neurodegenerative diseases. Hospital-treated infections, especially in early- and mid-life, were associated with an increased risk of AD and PD, primarily among AD and PD cases diagnosed before 60 years. These findings suggest that infectious events may be a trigger or amplifier of a preexisting disease process, leading to clinical onset of neurodegenerative disease at a relatively early age. However, due to the observational nature of the study, these results do not formally prove a causal link.