Pneumocystis is an opportunistic fungus that causes potentially fatal pneumonia (PCP) in immunocompromised patients. The objective of this study was to determine the prevalence of P. jirovecii in HIV patients through phenotypic and molecular study, to investigate the genetic polymorphisms of P. jirovecii at the mitochondrial gene mtLSU and at the nuclear dihydropteroate synthase gene (DHPS), and by analysis of molecular docking to study the effect of DHPS mutations on the enzymatic affinity for sulfamethoxazole. A PCP prevalence of 28.3% was detected, with mtLSU rRNA genotypes 3 (33.3%) and 2 (26.6%) being the most common. A prevalence of 6.7% (1/15) mutations in the DHPS gene was detected, specifically at codon 55 of the amino acid sequence of dihydropteroate synthase. Molecular docking analysis showed that the combination of mutations at 55 and 98 codons is required to significantly reduce the affinity of the enzyme for sulfamethoxazole. We observed a low rate of mutations in the DHPS gene, and molecular docking analysis showed that at least two mutations in the DHPS gene are required to significantly reduce the affinity of dihydropteroate synthase for sulfamethoxazole.