To understand the potential genetic basis of highland adaptation of fungal pathogenicity, we present here the -116 Mb de novo assembled high-quality genome of Ophiocordyceps sinensis endemic to the Qinghai-Tibetan Plateau. Compared with other plain-dwelling fungi, we find about 3.4-fold inflation of the O. sinensis genome due to a rapid amplification of long terminal repeat retrotransposons that occurred -38 million years ago in concert with the uplift of the plateau. We also observe massive removal of thousands of genes related to the transport process and energy metabolism. O. sinensis displays considerable lineage-specific expansion of gene families functionally enriched in the adaptability of low-temperature of cold tolerance, fungal pathogenicity and specialized host infection. We detect signals of positive selection for genes involved in peroxidase and hypoxia to enable its highland adaptation. Resequencing and analyzing 31 whole genomes of O. sinensis, representing nearly all of its geographic range, exhibits latitude-based population divergence and nature selection for population inhabitation towards higher altitudes on the Qinghai-Tibetan Plateau.