A variety of empirical and theoretical trade papers have suggested and documented a positive impact of trade on the productivity of firms. However, there is less consensus about the underlying mechanism at work. While trade papers focus on access to export markets, other papers stress the importance of import competition. Since imports and exports (and even tariffs affecting either) are usually highly correlated, it is unclear which mechanism the existing empirical papers uncover. This paper conducts a “horse race” between export opportunities and import competition. Using Spanish firm level data, instrumenting for exports and imports with tariff changes and controlling for selection, I find robust evidence that access to export markets leads to productivity increases, but only for firms that were already highly productive before. The evidence on import competition is weaker. If anything, initially low-tech firms manage to increase their productivity in response to increased competition from abroad. The latter finding is at odds with most trade models, so I propose a model incorporating non-profit maximizing managers to reconcile theory with the evidence. Empirically, I find that all productivity upgrades are driven by increased R&D, patenting, and product innovation. Access to export markets also leads to the adaptation of foreign technologies. There is no evidence that either mechanism leads to increased full time employment, instead full time workers seem to be replaced by part-time or temporary workers