Genomic diversity is shaped by a myriad of forces acting in different directions. Some genes work in concert with the interests of the organism, often shaped by natural selection, while others follow their own interests. The latter genes are considered “selfish”, behaving either neutrally to the host, or causing it harm. In this thesis, I focused on genes that have substantial fitness effects on the fungus Podospora anserina and relatives, but whose effects are very contrasting. In Papers I and II, I explored the evolution of a particular type of selfish genetic elements that cause meiotic drive. Meiotic drivers manipulate the outcome of meiosis to achieve overrepresentation in the progeny, thus increasing their likelihood of invading and propagating in a population. In P. anserina there are multiple meiotic drivers but their genetic basis was previously unknown. In Paper I, we demonstrated that drive is caused by members of the Spok gene family. We discovered two new Spok genes, Spok3 and Spok4, which locate in different chromosomes in different strains. In Paper II, we showed that Spok3 and Spok4 are found on a gigantic (up to 247 Kb long) variant of Enterprise, a Crypton-like transposable element. Enterprise likely mobilize through the action of a putative tyrosine-recombinase that we call Kirc. When carrying the Spoks, this element has double selfish properties: transposition and meiotic drive. In addition, we found that homologs of the Spoks (Paper I) and of Kirc (Paper II) are widespread in fungi but their phylogenies are discordant with that of the species, suggesting that they have undergone horizontal gene transfer. In Papers III and IV, I turned the focus into genes that have an adaptive function. In fungi, the het genes control conspecific self/non-self recognition. Such genes are expected to evolve under frequency-dependent balancing selection. In Paper III, we found evidence of balancing selection acting on some het genes across the P. anserina species complex. Unexpectedly, we also discovered that het genes of the HNWD gene family are duplicated in a transposon-like manner, broadening our understanding of their potential fitness effects. Finally, in Paper IV we show how het genes with pleiotropic effects on sexual recognition lead to the evolution of strong reproductive isolation, and hence speciation. Overall, the results of my thesis highlight the functional intersection between mobile selfish genetic elements and other genes, either selfish or adaptive, and their effects on genome architecture and population structure