Background Herpes simplex encephalitis can trigger autoimmune encephalitis that leads to neurological worsening. We aimed to assess the frequency, symptoms, risk factors, and outcomes of this complication. Methods We did a prospective observational study and retrospective analysis. In the prospective observational part of this study, we included patients with herpes simplex encephalitis diagnosed by neurologists, paediatricians, or infectious disease specialists in 19 secondary and tertiary Spanish centres (Cohort A). Outpatient follow-up was at 2, 6, and 12 months from onset of herpes simplex encephalitis. We studied another group of patients retrospectively, when they developed autoimmune encephalitis after herpes simplex encephalitis (Cohort B). We compared demographics and clinical features of patients who developed autoimmune encephalitis with those who did not, and in patients who developed autoimmune encephalitis we compared these features by age group (patients ≤4 years compared with patients >4 years). We also used multivariable binary logistic regression models to assess risk factors for autoimmune encephalitis after herpes simplex encephalitis. Findings Between Jan 1, 2014, and Oct 31, 2017, 54 patients with herpes simplex encephalitis were recruited to Cohort A, and 51 were included in the analysis (median age 50 years [IQR 5–68]). At onset of herpes simplex encephalitis, none of the 51 patients had antibodies to neuronal antigens; during follow-up, 14 (27%) patients developed autoimmune encephalitis and all 14 (100%) had neuronal antibodies (nine [64%] had NMDA receptor [NMDAR] antibodies and five [36%] had other antibodies) at or before onset of symptoms. The other 37 patients did not develop autoimmune encephalitis, although 11 (30%) developed antibodies (n=3 to NMDAR, n=8 to unknown antigens; p<0·001). Antibody detection within 3 weeks of herpes simplex encephalitis was a risk factor for autoimmune encephalitis (odds ratio [OR] 11·5, 95% CI 2·7–48·8; p<0·001). Between Oct 7, 2011, and Oct 31, 2017, there were 48 patients in Cohort B with new-onset or worsening neurological symptoms not caused by herpes simplex virus reactivation (median age 8·8 years [IQR 1·1–44·2]; n=27 male); 44 (92%) patients had antibody-confirmed autoimmune encephalitis (34 had NMDAR antibodies and ten had other antibodies). In both cohorts (n=58 patients with antibody-confirmed autoimmune encephalitis), patients older than 4 years frequently presented with psychosis (18 [58%] of 31; younger children not assessable). Compared with patients older than 4 years, patients aged 4 years or younger (n=27) were more likely to have shorter intervals between onset of herpes simplex encephalitis and onset of autoimmune encephalitis (median 26 days [IQR 24–32] vs 43 days [25–54]; p=0·0073), choreoathetosis (27 [100%] of 27 vs 0 of 31; p<0·001), decreased level of consciousness (26 [96%] of 27 vs seven [23%] of 31; p<0·001), NMDAR antibodies (24 [89%] of 27 vs 19 [61%] of 31; p=0·033), and worse outcome at 1 year (median modified Rankin Scale 4 [IQR 4–4] vs 2 [2–3]; p<0·0010; seizures 12 [63%] of 19 vs three [13%] of 23; p=0·001). Interpretation The results of our prospective study show that autoimmune encephalitis occurred in 27% of patients with herpes simplex encephalitis. It was associated with development of neuronal antibodies and usually presented within 2 months after treatment of herpes simplex encephalitis; the symptoms were age-dependent, and the neurological outcome was worse in young children. Prompt diagnosis is important because patients, primarily those older than 4 years, can respond to immunotherapy. Funding Mutua Madrileña Foundation, Fondation de l'Université de Lausanne et Centre Hospitalier Universitaire Vaudois, Instituto Carlos III, CIBERER, National Institutes of Health, Generalitat de Catalunya, Fundació CELLEX.