We characterise endogenous market structures under Bertrand and Cournot competition in a DSGE model. Short-run mark ups vary countercyclically because of the impact of entry on competition. Long-run mark ups are decreasing in the discount factor and in productivity, and increasing in the exit rate and in the entry costs. Dynamic inefficiency can emerge due to excessive entry under Cournot competition. Positive temporary shocks attract entry, which strengthens competition so as to reduce the mark ups temporarily and increase real wages: this competition effect creates an intertemporal substitution effect which boosts consumption and employment. Endogenous market structures improve the ability of a flexible prices model in matching impulse response functions and second moments for US data.