Heterospory is the production of spores from sporophytes of two different sizes and sexes of land plants . The smaller of these, the microspore , is the male and the larger the megaspore is the female. Heterospory evolved during the period from the Devonian to isospory : clubmosses , arborescent horsetails ,  and progymnosperms, independently in several plant groups. This occurred as part of a process of evolution at the time of sex discrimination.
Origin of heterospory
Heterospory evolved due to natural selection that favored an increase in proliferation size compared to smaller spores of homologous plants.  Heterosporic plants, similar to anisoporic plants, produce two different sized spores in separate sporangia that develop into separate male and female gametophytes.    It is proposed that the emergence of heterosporangia plants began with the separation of sporangia,  which allowed the development of two distinct types of spores; Many small spores that spread easily, and fewer, larger spores that have enough resources to support the developing seedling.  During the Devonian period there were many species that used vertical growth to capture more sunlight. Heterospory and separate sporangia probably evolved in response to competition for light.  Disruptive selection within species results in two different sexes of gametes or the entire plant. This can lead to an increase in spore size, and eventually the species can produce large megaspores as well as smaller microspores.  
Heterospory is advantageous in that having two different types of spores increases the likelihood that plants will successfully produce offspring.  Heterozygous spores can respond independently to selection by ecological conditions to strengthen male and female reproductive functions.  Heterospory sometimes evolved from homospory, but the species in which it first appeared is now extinct.  Heterospory is believed to have emerged in the Devonian era, mostly in wet/wet locations based on fossil record evidence. In addition to being the result of competition for light, it is believed that heterospory was more successful in wet areas because megaspores could move around more easily in aquatic environments while microspores were more easily dispersed by air.   Spores of varying sizes have been observed in many fossil plant species.  For example, the genus Lepidophloos , also known as the scale tree, has been shown to be heterosporous in fossils;  Scale trees had distinct cones that contained either male or female spores on the same plant.  Modern heterosporous plants such as many ferns exhibit endospory, in which a megagametophyte is fertilized by a microgametophyte, receiving nutrients from inside the spore, all while still inside the spore wall.  Both heterospory and endospory appear to be one of the many precursors of seed plants and ovaries.    Seed-producing heterosporic plants are their most successful and widespread descendants.  Seed plants form the largest subdivision of heterosporic plants.
Microspores and Megaspores
Microspores are haploid spores that contain the male gametophyte in endosporic species, which are carried to megaspores by wind, water currents or animal vectors, microspores are almost all non-flagellated, and therefore not capable of active motion.  The morphology of the microspore consists of a dense cytoplasm and an outer double-walled structure around a central nucleus.
Megaspores contain female gametophytes in heterosporic plant species . They develop archegonia which produce egg cells that are fertilized by the sperm of the male gametophyte produced from microspores. This results in the formation of a fertilized diploid zygote, which develops into the sporophyte embryo. While heterosporous plants produce fewer megaspores, they are significantly larger than their male counterparts.
In exosporic species, small spores germinate into free-living male gametophytes and large spores germinate into free-living female gametophytes. In endosporic species, gametophytes of both sexes are very highly reduced and contained within the spore wall. Microspores of both exosporic and endosporic species are free-spores, distributed by wind, water or animal vectors, but in endosporic species the megaspore and the megagametophyte contained within are retained and nourished by the sporophyte stage. Endosporic species are thus typically dioecious, a condition that promotes outcrossing. Some exosporic species produce microspores and megaspores in the same sporangium, a condition known as homangi. While in others microspores and megaspores are produced in separate sporangia (heterangi). Both of these can be carried on the same hermaphrodite sporophyte or on separate sporophytes in dioicous species.
Heterospory was an important event in the evolution of both fossil and living plants. The retention of megaspores and the dispersal of microspores allow for both dispersal and establishment of reproductive strategies. This adaptive ability of heterospory enhances reproductive success because either type of environment favors these two strategies. Heterospory prevents self-fertilization from occurring in a gametophyte, but does not prevent two gametophytes that result from mating with the same sporophyte.  This specific type of self-fertilization is called sporophytic selfing, and it usually occurs in angiosperms. While heterospory prevents excessive inbreeding from occurring, it does not completely prevent inbreeding because sporophytic selfing can still occur. 
A complete model for the origin of heterospory, known as the Haig–Westobi model,  establishes a relationship between minimal spore size and the successful reproduction of bisexual gametophytes. For female function, as the minimum spore size increases, so does the probability of successful reproduction. For male function, reproductive success does not change as the minimum spore size increases.