The aim of this study was to compare the type and antimicrobial resistance patterns of bacteria cultured from blood or respiratory tract secretions by HIV status and the use of trimethoprim-sulphamethoxazole (TMP-SMX) prophylaxis in children hospitalized with community-acquired pneumonia. During a 1-year prospective study in Cape Town, South Africa, 250 children [median aged 6 (3-16) months] hospitalized with pneumonia were enrolled; 151 (60.4 per cent) were HIV-infected. The incidence of bacteremia [35 of 244 cultures (14.3 per cent)] did not differ by HIV status. Bacteria were cultured in 17 of 32 (53 per cent) bronchoalveolar lavage specimens (BAL), 128 of 210 (61 per cent) induced sputa and 166 of 231 (71 per cent) nasopharyngeal specimens (NPAs). The type and number of bacteria in respiratory secretions did not differ by HIV status, except for a higher rate of Staphylococcus aureus in sputum or BAL [22 of 146 (15 per cent) vs. 3 of 96 (3 per cent), p = 0.003] and NPAs [41 of 135 (30 per cent) vs. 9 of 96 (9 per cent), p < 0.001] of HIV-positive children. The use of TMP-SMX prophylaxis in HIV-infected children was associated with an increased nasopharyngeal carriage of S. aureus [22 of 51 (43 per cent) vs. 17 of 79 (22 per cent), p = 0.009]. The rising prevalence of HIV infection and the use of TMP-SMX prophylaxis may alter the spectrum of colonizing and pathogenic bacteria in children in developing countries.