This paper analyzes the extent to which the reduction of import tariffs – as a measure of import competition – affects the rate of quality upgrading in the agri-food sector. This relation is studied using highly disaggregated EU-15 import data from more than 70 countries in thousands of food products, in the period 1995-2007. We first infer product quality from trade data using the method recently proposed by Khandelwal (2010). In a second step, quality estimates are combined with information on trade policy to study the relationship between quality upgrading and competition within a ‘distance to the frontier’ model (Aghion et al. 2005). Consistent with the model predictions, we find strong support for the existence of an non-monotonic relationship between competition and quality upgrading, with varieties close to the world frontier more likely to upgrade quality in response to an increase in import competition. The results are robust to the use of different measures of import competition and alternative estimates of product quality.