This paper studies how competition and vertical structure jointly determine generating capacities, retail prices, and welfare in the electricity industry. Analyzing a model in which demand is uncertain and retailers must commit to retail prices before they buy electricity in the wholesale market, we show that welfare is highest if competition in generation and retailing is combined with vertical separation. Vertically integrated generators choose excessively high retail prices and capacities to avoid rent extraction in the wholesale market when their retail demand exceeds their capacity. Vertical separation eliminates the risk of rent extraction and yields lower retail prices.