The outbreak of coronavirus disease 2019 (COVID-19) continues to spread worldwide and has led to recession, rising unemployment, and the collapse of the health-care system. The aim of this study was to explore the exposure–response relationship between daily confirmed COVID-19 cases and environmental factors. We used a time-series generalized additive model (GAM) to investigate the short-term association between COVID-19 and environmental factors by using daily meteorological elements, air pollutant concentration, and daily confirmed COVID-19 cases from January 21, 2020, to February 29, 2020, in Shanghai, China. We observed significant negative associations between daily confirmed COVID-19 cases and mean temperature (T
ave
), temperature humidity index (THI), and index of wind effect (K), whereas air quality index (AQI), PM
2.5
, PM
10
NO
2
, and SO
2
were significantly associated with the increase in daily confirmed COVID-19 cases. A 1 °C increase in T
ave
, one-unit increase in THI, and 10-unit increase in K (lag 0–7 days) were associated with 4.7, 1.8, and 1.6% decrease in daily confirmed cases, respectively. Daily T
ave
, THI, K, PM
10
, and SO
2
had significant lag and persistence (lag 0–7 days), whereas the lag and persistence of AQI, PM
2.5
, and NO
2
were significant at both lag 0–7 and 0–14 days. A 10-μg/m
3
increase in PM
10
and 1-μg/m
3
increase in SO
2
was associated with 13.9 and 5.7% increase in daily confirmed cases at lag 0–7 days, respectively, whereas a 10-unit increase in AQI and a 10-μg/m
3
increase in PM
2.5
and NO
2
were associated with 7.9, 7.8, and 10.1% increase in daily confirmed cases at lag 0–14 days, respectively. Our findings have important implications for public health in the city of Shanghai.