The paper investigates socially optimal patterns of economic growth and environmental quality in a neoclassical growth model with endogenous technological progress. In the model, the environmental quality affects positively not only to utility but also to production. However, cleaner technologies can be used in the economy whether a part of the output is used in environmentally oriented R&D. In this framework, if the initial level of capital is low then the shadow price of a cleaner technology is low relative to the cost of developing it given by the marginal utility of consumption and it is not worth investing in R&D. Thus, there will be a first stage of growth based only on the accumulation of capital with a decreasing environmental quality until the moment that pollution is great enough to make profitable the investment in R&D. After this turning point, if the new technologies are efficient enough, the economy can evolve along a balanced growth path with an increasing environmental quality. The result is that the optimal investment pattern supports an environmental Kuznets curve.