Background: Diabetes-associated cognitive decline (DACD) is one of the complications of diabetes and leads to cognitive impairment and an increased risk of dementia. However, the exact mechanism of DACD has not been fully characterized, and a successful therapy for this issue has not been established. This study aimed to detect the anti-apoptotic and anti-inflammatory effects of hydrogen sulfide (H2S) on DACD. Methods: We used a behavioural scoring method, Western blot, TUNEL staining and immunofluorescence staining to investigate the expression of the mitochondrial apoptotic pathway and the IL-23/IL-17 axis in db/db mice with or without sodium hydrosulfide (NaHS) administration. Results: NaHS administration mice exhibited reduced time to find the platform and a shorter swimming distance (P<0.05), while the time spent in the target quadrant was increased compared to that of the db/db group (P<0.05). Pro-apoptotic proteins, including cleaved Caspase-3, cleaved Caspase-9, Bax and cytochrome C, were elevated in the db/db group (P<0.01) but were downregulated in the db/db+NaHS group (P<0.05). Exogenous H2S decreased the numbers of TUNEL-positive cells in the db/db mice (P<0.05). The Western blot analysis showed that the expression levels of IL-23/IL-17 were lower in the NaHS administration group than in the db/db group (P<0.05). Conclusion: We demonstrated that H2S improved the spatial learning and memory abilities of the db/db mice by modulating the mitochondrial apoptotic pathway and the IL-23/IL-17 axis, which were found to be associated with DACD. H2S treatment may help prevent the progression of apoptotic hippocampal neurons in db/db mice and inform the development of a new therapeutic target.