Background: Although current studies have identified sleep disorders as an independent risk factor for suicide, the relationship between sleep disorders and suicide risk has not been well established. This study explored whether anxiety and depressive symptoms are used as mediators to participate in the impact of sleep quality on suicide risk. Methods: This is a cross-sectional study. We administered a psychological questionnaire to the participants, using a combination of self-assessment and psychiatrist assessment.Sleep quality, suicide risk, level of anxiety and depressive symptoms were assessed by PSQI, NGASR, SAS and SDS.The study subjects were 391 hospitalized COVID-19 patients from Wuhan hospitals. We used model 6 in the PROCESS (version 3.5) plug-in of SPSS software to conduct mediation test with sleep quality as the independent variable, suicide risk as the dependent variable, level of anxiety and depressive symptoms as intermediate variables. Results: The severity of anxiety and depressive symptoms and the risk of suicide in the sleep disorder group (63.15 ± 13.71, 59.85 ± 13.38, 6.52 ± 3.67) were higher than those in the non-sleep disorder group (49.83 ± 13.14, 44.87 ± 10.19, 2.87 ± 3.26) (P < 0.001). The mediation model works well, The total indirect effect was 0.22 (95%CI = [0.17, 0.28]), and the direct effect was 0.16 (95%CI = [0.08, 0.24]).