Brazil's trade liberalization between 1990 and 1993, and its partial reversal in 1995, are used to study how reduced inward trade barriers affect productivity. The production function of Brazilian manufacturers is estimated at the ISIC3 two-digit level under various alternatives, including an extension of Olley and Pakes' (1996) procedure. Firm-level productivity is inferred and then related to trade. Findings suggest that (1) foreign competition pressures firms to raise productivity markedly, whereas (2) the use of foreign inputs plays a minor role for productivity change. (3) The shutdown probability of inefficient firms rises with competition from abroad, thus contributing positively to aggregate productivity. Counterfactual simulations indicate that the competitive push (1) is an important source of immediate productivity change, while the elimination of inefficient firms (3) unfolds its impact slowly.