Vaccine immunogenicity and effectiveness vary geographically. Chronic immunomodulating parasitic infections including schistosomes and malaria have been hypothesised to be mediators of geographical variations. We compared vaccine-specific immune responses between three Ugandan settings (schistosome-endemic rural, malaria-endemic rural, and urban) and did causal mediation analysis to assess the role of Schistosoma mansoni and malaria exposure in observed differences. We used data from the control groups of three linked randomised trials investigating the effects of intensive parasite treatment among schoolchildren. All participants received the BCG vaccine (week 0); yellow fever (YF-17D), oral typhoid (Ty21a), human papillomavirus (HPV; week 4); and HPV booster and tetanus-diphtheria (week 28). Primary outcomes were vaccine responses at week 8 and, for tetanus-diphtheria, week 52. We estimated the total effect (TE) of setting on vaccine responses and natural indirect effect (NIE) mediated through current or previous infection with S mansoni or malaria, and baseline vaccine-specific responses. We included 239 (43%) participants from the schistosomiasis-endemic setting, 171 (30%) from the malaria-endemic setting, and 151 (27%) from the urban setting. At week 8, vaccine responses were lower in rural settings: schistosomiasis-endemic versus urban settings (TE geometric mean ratio for YF-17D plaque reduction neutralisation at 50% (PRNT50) titres 0·58 [95% CI 0·37 to 0·91], for S Typhi O-lipopolysaccharide-specific IgG 0·61 [0·40 to 0·93], and for tetanus-specific IgG 0·33 [0·22 to 0·51]); malaria-endemic versus urban settings (YF-17D 0·70 [0·49 to 0·99], S Typhi O-lipopolysaccharide-specific IgG 0·29 [0·20 to 0·43], and tetanus-specific IgG 0·53 [-0·35 to 0·80]). However, we found higher BCG-specific IFNγ responses in the malaria-endemic versus urban setting (1·54 [1·20 to 1·98]). The estimated NIEs of setting on vaccine responses mediated through previous and current S mansoni and malaria were not statistically significant. For malaria-endemic versus urban settings, baseline vaccine-specific responses contributed to some but not all differences: S Typhi O-lipopolysaccharide-specific IgG at week 8 (57.9% mediated [38·6 to 77·2]) and week 52 (70·0% mediated [49·4 to 90·6]) and BCG at week 52 (46.4% mediated [-4·8 to 97·7]). We found significant variation in vaccine response between urban and rural settings but could not confirm a causal role for schistosome or malaria exposure. Other exposures require consideration. UK Medical Research Council.