Poor sleep quality has been found to affect students’ learning abilities, academic performance, and interpersonal relationships. However, little is known about this issue in Nepal. This study aimed to identify the factors associated with poor sleep quality among undergraduate medical students in Nepal. A web-based survey was conducted in March 2021 among 212 undergraduate medical students at the Institute of Medicine, Kathmandu, Nepal. Sleep quality was measured using a 19-item Pittsburgh Sleep Quality Index (PSQI). Multivariable logistic regression analysis was done to assess the factors associated with sleep quality. In the study participants, 38.2% of the students were identified as poor sleepers. Factors like being depressed (AOR = 4.5, 95% CI; 1.2–5.4), current alcohol use (AOR = 2.5, 95% CI; 1.8–10.8), poor academic achievement (AOR = 3.4, 95% CI; 1.1–10.9), and being a fourth-year student (AOR = 3.6, 95% CI; 1.1–11.8) were significantly associated with poor sleep quality. Poor sleep quality was common among undergraduate medical students. Routine screening of sleep quality and depressive symptoms is necessary to mitigate their impact among medical students. Medical students of the fourth year, current alcohol users, and those who did not have good academic achievement had poor sleep quality. Special attention on these population subgroups is thus needed to enhance sleep quality.