We develop and quantify a multi-country and multi-sector endogenous growth model in which comparative advantage and the stock of knowledge are endogenously determined by innovation and knowledge diffusion. We quantify the effect of trade liberalization on innovation, comparative advantage and welfare in a framework that features intersectoral production and knowledge linkages that are consistent with the data. A reduction in trade frictions induces a reallocation of innovation and comparative advantage across sectors: innovation reallocates towards sectors that experience larger increases in comparative advantage, and comparative advantage reallocates towards sectors with stronger knowledge spillovers. Furthermore, knowledge spillovers amplify the effect of a trade liberalization as countries and sectors benefit from foreign technology. In contrast to standard one sector models of trade and innovation without knowledge spillovers, we find significant dynamic gains from trad e. These gains are mainly driven by innovation and knowledge diffusion across sectors and countries.