Gastrulation constitutes a fundamental yet diverse morphogenetic process of metazoan development. Modes of gastrulation range from stochastic translocation of individual cells to coordinated infolding of an epithelial sheet. How such morphogenetic differences are genetically encoded and whether they have provided specific developmental advantages is unclear. Here we identify two genes, folded gastrulation and t48, which in the evolution of fly gastrulation acted as a likely switch from an ingression of individual cells to the invagination of the blastoderm epithelium. Both genes are expressed and required for mesoderm invagination in the fruit fly Drosophila melanogaster but do not appear during mesoderm ingression of the midge Chironomus riparius. We demonstrate that early expression of either or both of these genes in C.riparius is sufficient to invoke mesoderm invagination similar to D.melanogaster. The possible genetic simplicity and a measurable increase in developmental robustness might explain repeated evolution of similar transitions in animal gastrulation.