Pistachio is a nut crop domesticated in the Fertile Crescent and a dioecious species with ZW sex chromosomes. We sequenced the genomes ofPistacia veracultivar (cv.) Siirt, the female parent, andP. veracv. Bagyolu, the male parent. Two chromosome-level reference genomes of pistachio were generated, and Z and W chromosomes were assembled. The ZW chromosomes originated from an autosome following the first inversion, which occurred approximately 8.18 Mya. Three inversion events in the W chromosome led to the formation of a 12.7-Mb (22.8% of the W chromosome) non-recombining region. These W-specific sequences contain several genes of interest that may have played a pivotal role in sex determination and contributed to the initiation and evolution of a ZW sex chromosome system in pistachio. The W-specific genes, includingdefA,defA-like,DYT1, twoPTEN1, and two tandem duplications of sixVPS13Aparalogs, are strong candidates for sex determination or differentiation. Demographic history analysis of resequenced genomes suggest that cultivated pistachio underwent severe domestication bottlenecks approximately 7640 years ago, dating the domestication event close to the archeological record of pistachio domestication in Iran. We identified 390, 211, and 290 potential selective sweeps in 3 cultivar subgroups that underlie agronomic traits such as nut development and quality, grafting success, flowering time shift, and drought tolerance. These findings have improved our understanding of the genomic basis of sex determination/differentiation and horticulturally important traits and will accelerate the improvement of pistachio cultivars and rootstocks.