We conducted a study of 126 patients with anal and rectal squamous cell carcinoma and 372 randomly selected control subjects in the San Francisco Bay Area (CA) to test the hypothesis that these tumors are related to a history of anal intercourse, the presence of sexually transmitted diseases and other conditions of the anal area, treatment of these diseases or conditions, and history of use of cigarettes or other substances. The relative risk (RR) of cancer was elevated for men with a history of homosexual activity (RR = 12.4, P less than .001). However, after adjustment for other risk factors, this risk was reduced to 2.7 (P = .28). Risk was elevated for homosexual male patients who reported a history of genital warts (RR = 12.6, P = .03), anal fissure or fistula (RR = 9.1, P = .05), and cigarette smoking (RR = 1.9 for 20 pack-yr, P less than .001; RR = 5.2 for 50 pack-yr, P less than .001). (Pack-year is a unit of cigarette use equal to 365 packs.) There was also elevated risk for heterosexual male and female patients who reported a history of genital warts (RR = 4.4, P = .003), anal fissure or fistula (RR = 2.4, P = .03), and more than 12 episodes of hemorrhoids (RR = 2.6, P less than .001). These findings suggest that anal cancer risk is etiologically related to human papillomaviruses that cause genital warts. In addition, constant irritation, chronic inflammatory changes, and repeated epithelial regeneration that accompany noninfectious conditions may be related to risk of anal cancer. The higher risk among homosexual men is related to the higher prevalence of anal cancer risk factors for this group.