Evolutionary transitions from oviparity to viviparity are frequent across diverse taxa. Some species also display intraspecific variation in parity mode, or they exhibit an intermediate mode by laying eggs containing embryos at variable, often advanced stages of development. How such natural quantitative variation in egg retention arises through differences in genetics, behaviour, and physiology - and how this variation ultimately connects to variation in specific fitness components - is not well-understood. Here, we study this problem by characterizing intraspecific variation in constitutive retention of fertilized eggs of the nematode Caenorhabditis elegans. Analysing a panel of ~300 wild strains, we find highly variable intra-uterine retention of fertilized eggs, with a fraction of strains showing either strongly reduced or increased egg retention with partial viviparity. We provide evidence for multiple evolutionary origins of such phenotypic extremes and we identify candidate loci explaining this natural variation. Characterizing a subset of wild strains, we confirm that natural variation in egg-laying behaviour contributes to observed differences in egg retention. Using multiple neuromodulatory agents and controlled CRISPR-Cas9-mediated genetic manipulation of endogenous serotonin levels in 10 wild strains, we then show that this behavioural variation arises through an evolutionarily divergent neuromodulatory architecture of the egg-laying circuitry. Intraspecific variation in C. elegans neural circuit activity therefore connects with variation in reproductive strategy, including transitions from oviparity to partial viviparity. In a second objective, we asked why natural variation in C. elegans egg retention might be maintained. Examining potential fitness costs and benefits of this natural variation, we show that strong egg retention reduces maternal fertility and survival, mostly due to detrimental larval hatching in utero. On the other hand, such genotypes with strong egg retention can benefit from improved offspring protection against environmental insults and by gaining a competitive advantage as offspring exhibit a shortened extra-uterine developmental time to reproductive maturity. Observed natural variation in C. elegans egg-laying behaviour may therefore reflect modifications of a trade-off between alternative fitness components expressed across generations. Our study uncovers underappreciated natural diversity in the C. elegans egg-laying circuit and provides insights into the fitness consequences of this behavioural variation. We propose that intraspecific variation in nematode egg-laying behaviour can serve as an ideal system to pinpoint the molecular changes underlying evolutionary transitions between invertebrate ovi- and viviparity.