Severe Acute Respiratory Syndrome Coronavirus-2 (SARS-CoV-2) infection, also known as COVID-19, has developed into an alarming situation around the world. Healthcare workers are playing the role of frontline defense to safeguard the lives of everyone during the COVID-19 pandemic. The present study aimed to investigate the anxiety levels and sleep quality among frontline and second-line healthcare workers during the COVID-19 pandemic. In this cross-sectional study, a validated, self-administered, electronic questionnaire was distributed through email to healthcare workers. The selection of 1678 healthcare workers was based on a convenience sampling technique. The General Anxiety Disorder-7 (GAD-7) and Pittsburgh Sleep Quality Index (PSQI) instrument scales were used to assess healthcare workers’ anxiety levels and sleep quality during the COVID-19 pandemic. Out of 1678 respondents, 1200 (71.5%) were frontline healthcare workers, while 478 (28.5%) were second-line healthcare workers. Among all the healthcare workers, 435 (25.92%) were experiencing moderate to severe anxiety. Among them, 713 (59.4%) frontline healthcare workers were experiencing anxiety in comparison with 277 (57.9%) second-line healthcare workers. Severe anxiety symptoms were seen in 137 (11.41%) frontline healthcare workers compared to 44 (9.20%) second-line healthcare workers. In total, 1376 (82.0%) healthcare workers were found to have poor sleep quality; 975 (58.10%) were frontline, and 407 (23.89%) were second-line healthcare workers. The highest poor sleep quality levels were found among 642 (84.6%) of the healthcare workers who work in frontline areas (emergency departments, intensive care units, and wards) compared to 734 (79.9%) of the healthcare workers who work in second-line areas. These findings provide a substantial contribution to the consolidation of evidence concerning the negative impact of the pandemic on the mental health of healthcare workers (HCWs). These results have established an association that the COVID-19 pandemic causes larger negative psychological symptoms in frontline healthcare workers, such as severe anxiety and poor sleep quality. Preventive measures to minimize anxiety levels and maintain sleep quality, addressing this issue nationally and globally, are essential to support the healthcare workers who are sacrificing their mental health for the future of our nations.