Fluctuations in investor demand dramatically affect firms' valuation and access to capital. To quantify its real impact, we develop a dynamic investment model that endogenizes both the demand- and supply-side of capital. Strong investor demand elevates equity prices and dampens price impacts of issuance, facilitating investment and financing, while weak investor demand instead incentivizes firms to optimally repurchase shares at favorable prices, which can crowd out investment, especially among firms with liquidity constraints. We estimate the model using indirect inference by matching the endogenous relationship between investors' portfolio holdings and firm characteristics. Our estimation suggests that investor demand substantially distorts firms' real investment decisions and impedes the efficient capital allocation across firms. Eliminating excess demand reduces dispersion in the marginal product of capital by 10.74% and TFP losses by 16.20%. Investor demand also influence firm size distributions and generates a heavy right tail---large excess demand provides firms with market power and opportunities to profit from their financial market activities, contributing to the emergence of superstar firms.