We develop a general equilibrium model with heterogeneous firms à la Melitz (2003), where both the government and firms can invest into R&D to improve the countrys technological potential. A higher technological potential raises the average productivity of firms, thus implying lower consumer prices, and eventually leads to a welfare gain. The governments public and firms private investments are modelled in a three-stage game, in which the government in the first stage invests into a basic research level, and then firms conduct private R&D building on this publicly provided "technology" in the second stage. We find that private R&D investments are hump-shaped with respect to the basic research level. For lower levels public and private investments are complements, while for higher levels they are substitutes.