Indirect development with an intermediate larva exists in all major animal lineages, and thus larvae are central to most scenarios for animal evolution. Yet how larvae evolved remains disputed. Here we show that changes in the timing of trunk formation underpin the diversification of larvae and bilaterian life cycles. Combining chromosome-scale genome sequencing with transcriptomic and epigenomic profiling in the slow-evolving oweniid Owenia fusiformis, we found that different genes and genomic regulatory elements control the development of its feeding larva and adult stage. First, O. fusiformis embryos develop into an enlarged anterior domain that forms larval tissues and the adult head, as posterior growth and trunk patterning is deferred to pre-metamorphic stages. These traits also occur in the so-called "head larvae" of other bilaterians, with whom O. fusiformis larva shows extensive transcriptomic similarities. Conversely, animals with non-feeding larvae and gradual metamorphoses, such as the annelid Capitella teleta, start trunk differentiation during embryogenesis, like direct developers. Together, our findings suggest that the ancestral temporal decoupling of head and trunk formation, as retained in extant "head larvae", allowed larval evolution in Bilateria, questioning prevailing scenarios that propose either co-option or innovation of gene regulatory programmes to explain larva and adult origins.