Background Allergy is commoner in developed than in developing countries. Chronic worm infections show inverse associations with allergy, and prenatal exposures may be critical to allergy risk. Objective To determine whether anthelminthic treatment during pregnancy increases the risk of allergy in infancy. Methods A randomised, double-blind, placebo-controlled trial on treatment in pregnancy with albendazole versus placebo and praziquantel versus placebo was conducted in Uganda, with a 2 × 2 factorial design; 2507 women were enrolled; infants’ allergy events were recorded prospectively. The main outcome was doctor-diagnosed infantile eczema. Results Worms were detected in 68% of women before treatment. Doctor-diagnosed infantile eczema incidence was 10.4/100 infant years. Maternal albendazole treatment was associated with a significantly increased risk of eczema [Cox HR (95% CI), p: 1.82 (1.26–2.64), 0.002]; this effect was slightly stronger among infants whose mothers had no albendazole-susceptible worms than among infants whose mothers had such worms, although this difference was not statistically significant. Praziquantel showed no effect overall but was associated with increased risk among infants of mothers with Schistosoma mansoni [2.65 (1.16–6.08), interaction p = 0.02]. In a sample of infants, skin prick test reactivity and allergen-specific IgE were both associated with doctor-diagnosed eczema, indicating atopic aetiology. Albendazole was also strongly associated with reported recurrent wheeze [1.58 (1.13–2.22), 0.008]; praziquantel showed no effect. Conclusions The detrimental effects of treatment suggest that exposure to maternal worm infections in utero may protect against eczema and wheeze in infancy. The results for albendazole are also consistent with a direct drug effect. Further studies are required to investigate mechanisms of these effects, possible benefits of worms or worm products in primary prevention of allergy, and the possibility that routine deworming during pregnancy may promote allergic disease in the offspring.