BackgroundThe COVID-19 pandemic is a serious global health concern, posing a greater risk of psychological vulnerabilities for frontline healthcare workers (HCWs), military professionals and the general public around the globe. These psychological issues appear to be long lasting and heighten the risk of mental health disorders. Therefore, this study aimed to identify psychological problems encountered by HCWs, military professionals, and the general public in Sri Lanka during the COVID-19 pandemic.MethodsA descriptive cross-sectional study was undertaken with 367 participants, including frontline HCWs (n = 128), military professionals (n = 102), and the general public (n = 137). Depression and anxiety were assessed using the Peradeniya Depression Scale (PDS) and the Generalized Anxiety Disorder scale (GAD-7), respectively.ResultsMean (± SD) age of the participants was 35.0 (±10.6) years. A reasonable proportion of participants experienced depressive symptoms (39.25%, n = 144) and severe anxiety (12.8%, n = 47). Military professionals showed depressive symptoms (73.50%, n = 75) and severe anxiety (32.4%, n = 33) predominantly. Multivariate binary logistic regression revealed that only the level of education and professional engagement affected depressive symptoms and severe anxiety (p < 0.01). Having a high level of education was a protective factor for depressive symptoms (Adjusted OR = 0.34) compared to lower-level education, while being a HCW (Adjusted OR = 4.40) and military professional (Adjusted OR = 5.43) were identified as risk factors for depressive symptoms compared to the general public. Similarly, having a high level of education was a protective factor for severe anxiety (Adjusted OR = 0.29) compared to lower-level education, while being a HCW (Adjusted OR = 3.90) and military professional (Adjusted OR = 4.52) were identified as risk factors for severe anxiety compared to the general public.ConclusionThe current study revealed a greater level of anxiety and depressive symptoms among frontline HCWs and military professionals in Sri Lanka during the pandemic of COVID-19 compared to the general public. Therefore, providing psychological first aid for them to better deal with mental problems and an emergency preparedness plan to deal with sudden outbreaks of infectious situations are important.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12888-023-04918-2.