Despite increasing studies on caterpillar (Insecta: Lepidoptera) gut microbiota, bacteria have been emphasized more than fungi. Therefore, we lack data on whether fungal microbiota is resident or transient and shaped by factors similar to those of bacteria. We sampled nine polyphagous caterpillar species from several tree species at multiple sites to determine the factors shaping leaf and gut bacterial and fungal microbiota as well as the extent to which caterpillars acquire microbiota from their diet. We performed 16S and ITS2 DNA metabarcoding of leaves and guts to determine the composition and richness of respective microbiota. While spatial variables shaped both the bacterial and fungal microbiota of the leaves, they only affected fungi in the guts, whereas bacteria were shaped primarily by caterpillar species, with some species harboring more specific bacterial consortia. Leaf and gut microbiota significantly differed; in bacteria, this difference was much more pronounced. Moreover, the leaf–gut similarity of bacterial but not fungal components differed significantly among caterpillar species, suggesting that some species have more transient bacterial microbiota than others. Our results suggest the complexity of the factors shaping the gut microbiota, while pointing out interspecific differences in microbiota residency within the same insect functional group.