This is a substudy of a larger randomized controlled trial on HIV-infected Zambian children, which revealed that cotrimoxazole prophylaxis reduced morbidity and mortality despite a background of high cotrimoxazole resistance. The impact of cotrimoxazole on the carriage and antibiotic resistance of Streptococcus pneumoniae and Haemophilus influenzae as major causes of childhood mortality in HIV-infected children was investigated since these are unclear. Representative nasopharyngeal swabs were taken prior to randomization for 181 of 534 children (92 on cotrimoxazole and 89 on placebo). Bacterial identification and antibiotic susceptibility were performed by routine methods. Due to reduced mortality, prophylactic cotrimoxazole increased the median time from randomization to the last specimen from 48 to 56 months (P = 0.001). The carriage of H. influenzae was unaltered by cotrimoxazole. Carriage of S. pneumoniae increased slightly in both arms but was not statistically significant in the placebo arm. In S. pneumoniae switching between carriage and no carriage in consecutive pairs of samples was unaffected by cotrimoxazole (P = 0.18) with a suggestion that the probability of remaining carriage free was lower (P = 0.10). In H. influenzae cotrimoxazole decreased switching from carriage to no carriage (P = 0.02). Cotrimoxazole resistance levels were higher in postbaseline samples in the cotrimoxazole arm than in the placebo arm (S. pneumoniae, P < 0.0001; H. influenzae, P = 0.005). Cotrimoxazole decreased switching from cotrimoxazole resistance to cotrimoxazole sensitivity in S. pneumoniae (P = 0.002) and reduced the chance of H. influenzae remaining cotrimoxazole sensitive (P = 0.05). No associations were observed between the percentage of CD4 (CD4%), the change in CD4% from baseline, child age at date of specimen, child gender, or sampling month with carriage of either pathogen.