HIV infected people and AIDS patients develop cancer more frequently than the general population. The objective of this study was to evaluate the risk of developing cancer among 15 to 69 year old AIDS patients from two geographic areas: Tarragona and Girona provinces, in north-eastern Spain. We have studied invasive and in situ cancers (for all sites) among 1659 AIDS patients from +/-5 years around the date of their AIDS diagnosis by matching the population-based Cancer Registries with the AIDS Registry covering these populations. The periods used in the linkage were 1981-1998 for Tarragona and 1994-1999 for Girona. Sex and age-standardised incidence ratios (SIRs) of observed-to-expected cancers were calculated by type of cancer as a measure of risk. For selected types of cancers, SIRs were also calculated for HIV exposure category. Compared with the general population, incidence of cancer among AIDS patients (invasive and in situ) increased 22.9 fold in men (n=142) and 21.0 fold in women (n=45). High statistically significant SIRs were found for Kaposi's sarcoma (KS) (male, 486.4; female, 1030.0), non-Hodgkin's lymphoma (NHL) (male, 126.1; female, 192.8) and invasive cervical cancer (41.8). High risks were also found for Hodgkin's lymphoma (31.1), liver cancer (29.4) and lung cancer (9.4) in men, and in situ cervical cancer (24.4) in women. For all non-AIDS defining malignant neoplasms as a group SIRs were 3.4 in men and 2.5 in women. Among men, homo/bisexuality was strongly related to risk of KS and NHL. The rates of cervical cancer, Hodgkin's lymphoma, liver cancer and lung cancer were among the highest ever reported linked to HIV infection. For the cervical cancer this could be attributable to the low incidence of this cancer in the general population and to the high prevalence of intravenous drug users among HIV women and probably due to poor preventive strategies in this population.