During the outbreak of the coronavirus disease 2019 (COVID-19), the medical staff was facing severe work pressure, which led to a negative emotional state. The purpose of this study was to explore the relationship between the family environment and the emotional state of the medical staff members during the COVID-19 outbreak. Due to the importance of self-efficacy in regulating mental health, the mediating role of self-efficacy in the association between family environment and emotional state was also explored. A cross-sectional survey was performed, using an online questionnaire, on 645 medical staff who participated in the epidemic prevention and control tasks during the COVID-19 outbreak in Beijing. Family environment, self-efficacy, anxiety, and depressive symptoms were measured by the Family Environment Scale-Chinese Version (FES-CV), the General Self-Efficacy Scale (GSES), the Generalized Anxiety Disorder Scale-7 (GAD-7), and the Patient Health Questionnaire-9 (PHQ-9), respectively. Correlation analysis and mediating effect analysis were used to explore the relationships between them. First, a higher prevalence of anxiety (39%) and depressive (33%) symptoms were confirmed among the medical staff. Second, the symptoms of anxiety and depression were negatively correlated with the dimensions of cohesion and expressiveness and positively correlated with the dimensions of conflict in the FES-CV scale. Third, self-efficacy significantly mediated the association between the family environment and anxiety symptoms (
P
< 0.001) as well as the family environment and depressive symptoms (
P
< 0.001). These findings show that a negative family environment was the main predictor of symptoms of anxiety and depression in the medical staff during the COVID-19 outbreak. Furthermore, we found that self-efficacy played a critical mediating role between the family environment and the symptoms of anxiety and depression. Our study also indicates that improvements in the family environment benefit the mental health care of the medical staff, and high self-efficacy enhances this effect.