The coronavirus disease 2019 (COVID-19) outbreak caused by the severe acute respiratory syndrome coronavirus 2 (SARS-Cov-2 virus) has been sustained in China since December 2019, and has become a pandemic. The mental health of frontline medical staff is a concern. In this study, we aimed to identify the factors influencing medical worker anxiety in China during the COVID-19 outbreak. We conducted a cross-sectional study to estimate the prevalence of anxiety among medical staff in China from 10 February 2020 to 20 February 2020 using the Zung Self-rating Anxiety Scale (SAS) to assess anxiety, with the criteria of normal (⩽49), mild (50–59), moderate (60–70) and severe anxiety (⩾70). We used multivariable linear regression to determine the factors (e.g. having direct contact when treating infected patients, being a medical staff worker from Hubei province, being a suspect case) for anxiety. We also used adjusted models to confirm independent factors for anxiety after adjusting for gender, age, education and marital status. Of 512 medical staff in China, 164 (32.03%) had had direct contact treating infected patients. The prevalence of anxiety was 12.5%, with 53 workers suffering from mild (10.35%), seven workers suffering from moderate (1.36%) and four workers suffering from severe anxiety (0.78%). After adjusting for sociodemographic characteristics (gender, age, education and marital status), medical staff who had had direct contact treating infected patients experienced higher anxiety scores than those who had not had direct contact (β value = 2.33, confidence interval (CI) 0.65–4.00; P = 0.0068). A similar trend was observed in medical staff from Hubei province, compared with those from other parts of China (β value = 3.67, CI 1.44–5.89; P = 0.0013). The most important variable was suspect cases with high anxiety scores, compared to non-suspect cases (β value = 4.44, CI 1.55–7.33; P = 0.0028). In this survey of hospital medical workers during the COVID-19 outbreak in China, we found that study participants experienced anxiety symptoms, especially those who had direct clinical contact with infected patients; as did those in the worst affected areas, including Hubei province; and those who were suspect cases. Governments and healthcare authorities should proactively implement appropriate psychological intervention programmes, to prevent, alleviate or treat increased anxiety.