Background: Sepsis-associated encephalopathy (SAE) is a complication of the central nervous system in patients with sepsis. Currently, no effective treatment for sepsis is available. Hydrogen plays a protective role in different diseases; however, the detailed mechanism of hydrogen-treated disease remains unclear. The purpose of this study was to investigate the effect of hydrogen on SAE in vitro and in vivo and the mechanism of hydrogen in mitochondrial dynamics and its function in astrocytes and microglia stimulated by lipopolysaccharides (LPSs). Methods: Animal models of SAE were generated by cecal ligation and puncture, and the SAE model was established by in vitro LPS stimulation. MTT, lactate dehydrogenase (LDH), reactive oxygen species (ROS), heme oxygenase-1 (HO-1) activity, mitochondrial membrane potential (MMP), and cell apoptosis assays were used to determine the effect of hydrogen on astrocytes and microglia stimulated by LPSs. The relationships between nuclear factor erythroid 2-related factor 2 (Nrf2), YY1, and HO-1 were examined by chromatin immunoprecipitation and co-immunoprecipitation. Mitochondrial homeostasis-related proteins in LPS-stimulated glial cells and brain tissues of SAE mice were detected by western blotting. The effects of hydrogen treatment in the SAE mouse model were investigated using Morris water maze and Y-maze analyses. Results: After performing experiments with different concentrations of LPSs in vitro, we selected 1000 ng/ml for subsequent experiments. Hydrogen attenuated the increase in ROS, LDH, and apoptosis and promoted decreases in cell activity and MMP, further promoting an increase in HO-1 expression induced by LPSs in astrocytes and microglia. Moreover, hydrogen further promoted the expression of Nrf2, HO-1, PGC-1α, TFAM, PARKIN, and PINK1, inhibited LPS-induced OPA1 and MFN2 expression in astrocytes and microglia, and downregulated the expression of DRP1 after LPS induction. Intriguingly, hydrogen treatment enhanced the binding between Nrf2 and YY1. However, silencing Nrf2 or YY1 abolished the protective effects of hydrogen on cell activity, LDH, ROS, and MMP; apoptosis; and regulation of Nrf2, HO-1, PGC-1α, TFAM, OPA1, DRP1, MFN2, PARKIN, and PINK1 in microglia. Finally, hydrogen treatment improved the results of behavioral detection, apoptosis, Nrf2, HO-1, PGC-1α, TFAM, OPA1, DRP1, MFN2, PARKIN, PINK1, and cytokines in SAE in vivo. Conclusions: Hydrogen improved cell injury and mitochondrial quality, which were associated with HO-1 expression promoted by the Nrf2/YY1 complex in vitro. Thus, hydrogen treatment may represent a novel therapeutic method for treating SAE.