This paper investigates several channels through which automation affects an emerging economy. Building on a Ricardian model of trade with sectoral linkages and a two-stage production technology, in which robots replace labor in certain tasks, it is shown that domestic and foreign automation have differential effects on labor markets. Based on this model, the impact of automation on local labor markets in Brazil are estimated using a shift-share approach. Local labor market exposures to industry-level stocks of robots are derived from their initial industry-employment composition. Foreign automation is found to decrease manufacturing employment through the channel of final goods exports, while it increases employment in the mining sector through the channel of input exports. This may stimulate what has been called "premature deindustrialization" in emerging economies. To account for possible endogeneity in adopting robots domestically, robot uptake in other emerging economies is used as an instrumental variable. Domestic automation is found to directly decrease the ratio of unskilled industry workers and increase the ratio of skilled workers. Also, the wage gap between the two groups widens as a consequence of domestic automation, reinforcing income inequality.