Background: There are many challenges that people face in their lives. Recently, the whole world was affecting because of a unique virus known as COVID-19 or coronavirus. Objective: To determine the impact of attending online classes on mental health among university students during the COVID-19 pandemic in Lahore. Methods: This cross-sectional study was conducted on 215 undergraduate students who were locked down in their homes during the COVID-19 pandemic and took online classes using the depression, anxiety, stress scale and online learning scale through convenient sampling. The demographics were reduced to numbers, percentages, and frequencies for analysis. The frequency and percentage of occurrence were selected as the presentation formats for qualitative variables. Cross-tabulation was used to see whether online learning was related to depression, anxiety, or stress levels. Results: Among 215 Undergraduate students, 53 (24.7%) were males and 162 (75.3%) were females. While 15 (7.0%) presented with symptoms, the level of depression was moderate among 65 (30.2%), severe 69 (32.1%) and extremely severe 81 (37.7%). Level of anxiety was moderate among 23 (10.7%), severe at 32 (14.9%) and extremely severe at 160 (74.4%) while the level of stress was normal 15 (7.0%), mild at 25 (11.6%), moderate 59(27.4%), severe 71 (33.0%) and extremely severe 45 (20.9%). There was a significant association between online classes and mental health including depression, anxiety and stress as the p-value was 0.029, 0.045 and 0.043 respectively. Conclusion: The level of depression, anxiety and stress was high among undergraduate university students during the COVID-19 pandemic. There was a significant impact of online classes on mental health symptoms including the level of depression, anxiety, and stress. Students taking online classes suffer from poor mental health.