BackgroundAs the medical undergraduates constitute the future workforce in China, their career preferences hold a significant bearing on the quality of healthcare services, particularly in light of the ongoing COVID-19 pandemic. We aim to understand the current state of the willingness to practice medicine among medical undergraduates and to analyze the related influential factors.MethodsDuring the COVID-19 epidemic, we conducted a cross-sectional survey via an online platform from February 15, 2022, to May 31, 2022, to collect participants’ demographic information, psychology, and factors influencing their career choices. The general self-efficacy scale (GSES) was used to evaluate medical students’ perceptions of their self-efficacy. Futhermore, we conducted multivariate logistic regression analyses to explore the influencing factors of medical undergraduates’ willingness to pursure a caree in medicine.ResultsA total of 2348 valid questionnaires were included, and 1573 (66.99%) were willing to practice medicine for medical undergraduates after graduation. The mean GESE scores in the willingness group (2.87 ± 0.54) were significantly higher than those of the unwillingness group (2.73 ± 0.49). The multiple logistic regression showed that several factors were positively associated with willingness to practice medicine as a career, including students’ GSES score (OR = 1.87), current major, household income, personal ideals (OR = 1.97), family support (OR = 1.44), high income (OR = 1.77), and social respect (OR = 2.19). Compared with those who were very afraid of COVID-19, students who did not express any fear towards the COVID-19 pandemic had a higher preference for choosing the medical profession as a career. Conversely, students thinking of high tension in the doctor-patient relationship, heavy workload, and long training were less likely to choose medical work after graduation.ConclusionsThe study highlights a noteworthy prevalence of medical undergraduates who expressed their willingness to pursue medicine as a career post-graduation. Several factors, including but not limited to current major, household income, psychological factors, personal preferences, and career needs or preferences, were significantly associated with this willingness. Moreover, the impact of the COVID-19 pandemic on medical students’ career choices cannot be overlooked.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12909-023-04418-7.