PurposeThis article investigates the mechanism of the direct and indirect effects of epidemics on agricultural production and projects the impact of COVID-19 on agricultural output in China.Design/methodology/approachThis article first adopts a dynamic panel model and spatial Durbin model to estimate the direct and indirect effects, followed by a growth accounting method to identify the channels by which epidemics affect agriculture; finally, it projects the overall impact of COVID-19 on agriculture.FindingsThe incidence rate of epidemics in a province has a negative impact on that province's own agricultural productivity, but the increase in the input factors (land, fertilizer and machinery) can make up for the loss and thus lead to insignificant direct effects. However, this “input-offset-productivity” mechanism fails to radiate to the surrounding provinces and therefore leads to significant indirect/spillover effects. It is projected that COVID-19 will lower China's agricultural growth rate by 0.4%–2.0% in 2020 under different scenarios.Research limitations/implicationsIt is crucial to establish a timely disclosure and sharing system of epidemic information across provinces, improve the support and resilience of agricultural production in the short run and accelerate the process of agricultural modernization in the long run.Originality/valueConsidering the infectivity of epidemics, this article evaluates the mechanism of the direct and indirect effects by introducing a spatial dynamic model into the growth accounting framework. Moreover, besides the impact on input portfolio and productivity, this article also investigates whether epidemics reshape agricultural production processes due to panic effects and control measures.