Development studies on the middle-income trap have highlighted the challenges for developing economies to transform their productive systems from simple towards high value-added activities. Here, we use trade data of 116 countries to quantify the stages of productive sophistication and reveal the critical phase that countries encounter at intermediate levels of economic sophistication. Our results reveal that only five countries (i.e. Ireland, Israel, Hungary, Singapore, and South Korea) overcame the gravitation towards simple products and fully transformed their economies towards complex products between 1970 and 2010. They successfully made use of windows of opportunities in the digital and electronics sectors through smart industrial policies that promoted endogenous skills and access to international knowledge sources. In contrast, countries like Brazil or South Africa still struggle with the gravitation towards simple economic activities, social fragmentation, and a lack of coherent industrial policies.