The origin of the germline-soma distinction in metazoans is a fundamental unsolved question. Somatic gametogenesis in sessile sponges and corals contrasts starkly with early germline sequestration in bilaterians with higher energy requirements, elaborate body plans and fast evolution of small mitochondrial genomes. We develop an evolutionary model to investigate whether selection for mitochondrial quality can drive germline evolution. In basal metazoans with low mutation rates, somatic gametogenesis optimizes gamete quality through segregation of mitochondrial mutations in multiple cell divisions. The need to maintain mitochondrial quality in somatic tissues explains the evolution of oogamy and male-female gamete specialization. Higher mitochondrial mutation rates promote early sequestration of a dedicated germline, permitting complex developmental processes. Rising oxygen drove germline evolution in motile bilaterians, igniting the Cambrian explosion.