Temporal trends in the incidence of opportunistic diseases (ODs) related to acquired immunodeficiency syndrome (AIDS) were studied during 1989-1997 in 1115 outpatients infected with human immunodeficiency virus (331 of whom had AIDS) in a hospital in Madrid, Spain. We analyzed the effect of adherence to antiretroviral therapy and Pneumocystis carinii pneumonia (PCP) prophylaxis on the incidence of OD. Diseases that showed a significant decreasing trend were esophageal candidiasis, pulmonary and extrapulmonary tuberculosis, and cerebral toxoplasmosis. Patients who adhered to antiretroviral therapy had a smaller risk of OD. Patients who adhered to PCP prophylaxis had a reduced risk of cerebral toxoplasmosis and PCP. A reduction in the incidence of AIDS-related ODs was observed, mainly in patients who underwent prophylaxis. Adherence to antiretroviral treatment and PCP prophylaxis was associated with a reduction in the risk of disease.