We use a rich dataset of Spanish manufacturing firms from 1990 to 2016 to shed new light on how automation in a high-income country affects trade and multinational activity involving lower-income countries. We exploit supply-side improvements in the capabilities of robots over time, as described in patents, that made it technically feasible to automate some specific tasks. We show that, contrary to the speculation that automation will cause reshoring, the use of robots in Spanish firms actually had a positive impact on their imports from, and number of affiliates in, lower-income countries. Robot adoption causes firms to expand production, increase productivity and makes them more likely to start importing from, or opening affiliates in, lower-income countries. The sequencing of automation and offshoring has important consequences for the impact of automation, however. For firms that had not already offshored to lower-income countries, robot adoption made them more likely to start doing so. By contrast, for firms that were already offshoring to lower-income countries, robot adoption had no effect on their value of imports from lower-income countries, but decreased their share of imports sourced from lower-income countries. We show that these findings can be explained in a framework that incorporates firm heterogeneity, the choice between automation, offshoring and performing tasks at home and where automation and offshoring both involve upfront fixed costs, such that their sequencing matters.