BACKGROUND: Understanding the adverse effects of proton pump inhibitors (PPIs) is important due to their widespread use, but the available evidence for an increased dementia risk among patients taking PPIs is inconclusive. The present study aimed to estimate the causal effect of PPIs on the risk of dementia by target trial emulation and time-varying exposure modeling. METHODS: Using claims data of 2,698,176 insured people of a large German statutory health insurer, we conceptualized a target trial in which individuals aged 40 years and older were classified as PPI initiators or non-initiators between 2008 and 2018, and followed until diagnosis of dementia, death, loss to follow-up or end of study. Incidence of dementia (ICD-10 codes F00, F01, F03, F05.1, G30, G31.0, G31.1, G31.9, and F02.8+G31.82) was defined applying a 1-year lag window. We used weighted Cox models to estimate the effect of PPI initiation vs. non-initiation on dementia risk and weighted pooled logistic regression to estimate the effect of time-varying use vs. non-use. RESULTS: 29,746 PPI initiators (4.4%) and 26,830 non-initiators (1.3%) were diagnosed with dementia. Comparing PPI initiation with no initiation, the hazard ratio (HR) for dementia was 1.54 (95% confidence interval [CI]: 1.51-1.58). The HR for time-dependent PPI use vs. non-use was 1.56 (95% CI: 1.50-1.63). Differentiated subtypes, including unspecified dementia, Alzheimer's disease (AD), and vascular dementia (VaD), showed increased risk by PPI initiation and time-varying PPI use. CONCLUSIONS: This study suggests that PPI initiation and time-varying PPI use may increase overall dementia risk.