We present an estimated dynamic stochastic general equilibrium model of stock market bubbles and business cycles using Bayesian methods. Bubbles emerge through a positive feedback loop mechanism supported by self-fulfilling beliefs. We identify a sentiment shock that drives the movements of bubbles and is transmitted to the real economy through endogenous credit constraints. This shock explains most of the stock market fluctuations and sizable fractions of the variations in real quantities. It generates the comovement between stock prices and the real economy, and is the dominant force behind the internet bubbles and the Great Recession.