Background: Pneumocystis pneumonia (PCP) is conventionally diagnosed by identifying Pneumocystis jirovecii in lower respiratory tract samples using cytochemical stains. Molecular diagnosis of PCP is potentially more sensitive. Methods: A study was undertaken to use an extensively optimised real-time polymerase chain reaction (PCR) using primers designed to hybridise with the P jirovecii heat shock protein 70 (HSP70) gene to quantify P jirovecii DNA in bronchoalveolar lavage (BAL) fluid from HIV-infected patients with and without PCP, and to compare this assay with conventional PCR targeting the P jirovecii mitochondrial large subunit rRNA gene sequence (mt LSU rRNA). Results: Sixty-one patients had 62 episodes of PCP (defined by detection of P jirovecii in BAL fluid by cytochemical stains and typical clinical presentation). Quantifiable HSP70 DNA was detected in 61/62 (range ∼13-18 608 copies/reaction; median ∼332) and was detectable but below the limit of quantification (∼5 copies/reaction) in 1/62. Seventy-one other patients had 74 episodes with alternative diagnoses. Quantifiable HSP70 DNA was detectable in 6/74 (8%) episodes (range ∼6-590 copies/reaction; median ∼14) and detectable but below the limit of quantification in 34/74 (46%). Receiver-operator curve analysis (cut-off >10 copies/reaction) showed a clinical sensitivity of 98% (95% 91% to 100%) and specificity of 96% (95% CI 87% to 99%) for diagnosis of PCP. By contrast, clinical sensitivity of mt LSU rRNA PCR was 97% (95% CI 89% to 99%) and specificity was 68% (95% CI 56% to 78%). Conclusion: The HSP70 real-time PCR assay detects P jirovecii DNA in BAL fluid and may have a diagnostic application. Quantification of P jirovecii DNA by real-time PCR may also discriminate between colonisation with P jirovecii and infection.