In the ciliate Paramecium, transposable elements and their single-copy remnants are deleted during the development of somatic macronuclei from germline micronuclei, at each sexual generation. Deletions are targeted by scnRNAs, small RNAs produced from the germ line during meiosis that first scan the maternal macronuclear genome to identify missing sequences, and then allow the zygotic macronucleus to reproduce the same deletions. Here we show that this process accounts for the maternal inheritance of mating types in Paramecium tetraurelia, a long-standing problem in epigenetics. Mating type E depends on expression of the transmembrane protein mtA, and the default type O is determined during development by scnRNA-dependent excision of the mtA promoter. In the sibling species Paramecium septaurelia, mating type O is determined by coding-sequence deletions in a different gene, mtB, which is specifically required for mtA expression. These independently evolved mechanisms suggest frequent exaptation of the scnRNA pathway to regulate cellular genes and mediate transgenerational epigenetic inheritance of essential phenotypic polymorphisms.