Eggs of insects are immobile and must endure harsh environmental conditions (e.g., low temperatures in winter and aridity in summer) and avoid attack by egg-eating predators, egg parasites, and microbes. Females of Megaloptera lay their eggs as a single- or multi-layered egg mass, which is coated with chemical substances secreted from the female reproductive accessory glands. In this study, we observed the egg masses laid by females of two species of Sialidae (alderflies), nine species of Chauliodinae (fishflies), and 23 species of Corydalinae (dobsonflies) belonging to the order Megaloptera and examined the functions of accessory gland substances coating the laid eggs. The female accessory gland is a single tube in alderflies and fishflies but a paired pouch in dobsonflies. The amount and color of the gland substances differ greatly among species. These substances prevent egg desiccation, inhibit egg feeding by ladybird beetles, and repel ants. Most characteristics of the egg mass structures and the effectiveness of accessory gland substances reflect the phylogeny of Megaloptera, although some differ among closely related taxa.