Recently, a COVID-19 virus variant spread rapidly in Guangzhou, China, causing public panic. This study aimed to understand the psychological and sleep-related consequences of the secondary outbreak of the pandemic on medical students. In this cross-sectional survey-based study, participants anonymously completed structured questionnaires online from June 8–22, 2021. We collected participants' demographic and general information. Anxiety, depression, and sleep quality were measured using the Zung Self-Rating Anxiety Scale (SAS), Self-Rating Depression Scale (SDS), and Pittsburgh Sleep Quality Index (PSQI), respectively. Protective factors were assessed using the Coping Style Questionnaire (CSQ). Uni- and multivariate logistic regression analyses were performed examining factors associated with mental health and sleep quality problems. During the second wave of the pandemic in local outbreak areas in Guangzhou, China, more than one-third of medical students' mental health and sleep quality were affected. The prevalence of anxiety, depression, and poor sleep quality were 27.54%, 27.58%, and 18.19%, respectively. Students belonging to the Class of 2019, aged over 29 years, those with siblings, and those whose hometowns were in other provinces were more prone to the three health problems. Factors associated with an increased risk of mental health problems were vaccination status (adjusted odds ratio 1.603–1.839) and diet status (adjusted odds ratio 1.62–1.929). Positive coping styles served as protective factors ( p < 0.05). We discovered that completed vaccination status, good diet, and positive coping styles were related to good mental health and sleep quality.