Moths and butterflies (Lepidoptera) usually have a pair of differentiated WZ sex chromosomes. However, in most lineages outside of the division Ditrysia, as well as in the sister order Trichoptera, females lack a W chromosome. The W is therefore thought to have been acquired secondarily. Here we compare the genomes of three Lepidoptera species (one Dytrisia and two non-Dytrisia) to test three models accounting for the origin of the W: (1) a Z-autosome fusion; (2) a sex chromosome turnover; and (3) a non-canonical mechanism (e.g., through the recruitment of a B chromosome). We show that the gene content of the Z is highly conserved across Lepidoptera (rejecting a sex chromosome turnover) and that very few genes moved onto the Z in the common ancestor of the Ditrysia (arguing against a Z-autosome fusion). Our comparative genomics analysis therefore supports the secondary acquisition of the Lepidoptera W by a non-canonical mechanism, and it confirms the extreme stability of well-differentiated sex chromosomes.