We analyzed the association of herpes simplex virus (HSV) infection and syphilis, the two most common causes of genital ulceration in homosexual men, with human immunodeficiency virus (HIV) infection in 200 men enrolled between 1983 and 1986 into a study evaluating the microbial causes of acute proctitis. Infection with HIV was independently associated with a history of syphilis, serologic evidence of syphilis, a history of HSV infection, and antibody to HSV-2. Antibody to HIV was not associated with a history of other genital infections or with antibody to Chlamydia trachomatis or HSV-1. Similar associations were observed in 111 asymptomatic homosexuals seen for HIV screening. Men who presented with primary HSV proctitis had a lower prevalence of HIV antibody than those with preexisting HSV-2 antibody (44% vs 68%); this suggests that HSV-2 infection antedated HIV infection. These data suggest that genital ulcerative diseases are an important risk factor for the acquisition of HIV infection in homosexual men; measures directed at control of these diseases may reduce the transmission of HIV in this population.