Insect societies are tightly integrated, complex biological systems in which group-level properties arise from the interactions between individuals. However, these interactions have not been studied systematically and therefore remain incompletely known. Using a reverse engineering approach, we discovered that, unlike solitary insects, ant pupae extrude a secretion derived from the molting fluid that is rich in nutrients, hormones, and neuroactive substances. This secretion elicits parental care behavior and is rapidly removed and consumed by the adults. This behavior is crucial for pupal survival; if the secretion is not removed, pupae develop fungal infections and die. Analogous to mammalian milk, the secretion is also an important source of early larval nutrition, and young larvae exhibit stunted growth and decreased survival without access to the fluid. We show that this derived social function of the molting fluid generalizes across the ants. This secretion thus forms the basis of a central and hitherto overlooked interaction network in ant societies, and constitutes a rare example of how a conserved developmental process can be coopted to provide the mechanistic basis of social interactions. Our results therefore imply a major role for molting fluids in the evolution of ant eusociality.