We analyze the endogenous formation of R&D networks, where firms are active in different product markets and can benefit from R&D spillovers form collaborating firms within or across different industries. R&D spillovers help firms to introduce process innovations to lower their production costs. Product innovations introduce an escape-competition effect, through which firms can enter new markets with fewer competitors. We provide a complete equilibrium characterization in which both, the network of R&D collaborations as well as the market structure, are endogenously determined. We show that the coevolution of market and network structure matter for the relationship between competition and innovation. Moreover, our model allows us to explain differences in the R&D network structures observed across different industries, and how they are related to different levels of competition in these industries.