ObjectiveTo explore the longitudinal association between blood count-derived immunoinflammatory markers and the risk of epilepsy in a large population cohort. MethodsWe used data from the UK Biobank (UKB) to investigate the association between pre-diagnostic peripheral immunoinflammatory cells and their derived ratios, including the neutrophil-to-lymphocyte ratio (NLR), platelet-to-lymphocyte ratio (PLR), lymphocyte-to-monocyte ratio (LMR), systemic immune-inflammation index (SII), and the risk of epilepsy. This was a longitudinal cohort study in which multivariate Cox proportional hazards models and a series of sensitivity and subgroup analyses were performed to explore the nature of these associations. ResultsWe examined these associations in a prospective UKB cohort of 497,291 participants. During a median follow-up of 12.43 years, 2,715 participants developed epilepsy. After adjusting for all covariates, the results showed that higher monocyte counts and some blood count-derived immunoinflammatory metrics (monocyte counts, hazard ratio [HR]=1.093, 95 % confidence interval [CI] 1.052–1.136, P<0.001; NLR, HR=1.062, 95 % CI 1.022–1.103, P=0.002; PLR, HR=1.096, 95 % CI 1.055–1.139, P<0.001; SII, HR=1.041, 95 % CI 1.003–1.082, P=0.036) were associated with an increased risk of epilepsy. Conversely, we found that higher lymphocyte counts and LMR were negatively associated with the risk of epilepsy (lymphocyte count, HR=0.889, 95 % CI 0.856–0.923, P < 0.001; LMR, HR=0.85, 95 % CI 0.82–0.881, P < 0.001). ConclusionsMonocyte count, NLR, PLR, and SII increased the risk of epilepsy, whereas lymphocyte count and LMR decreased it. Further studies will help translate these findings into clinical practice or targeted treatments.