Background: Rectal chlamydia is a common bacterial sexually transmissible infection among men who have sex with men. Data from randomized, controlled trials are needed to guide treatment. Methods: In this double-blind trial conducted at five sexual health clinics in Australia, we randomly assigned men who have sex with men and who had asymptomatic rectal chlamydia to receive doxycycline (100 mg twice daily for 7 days) or azithromycin (1-g single dose). Asymptomatic chlamydia was selected as the trial focus because more than 85% of men with rectal chlamydia infection are asymptomatic, and clinical guidelines recommend a longer treatment course for symptomatic infection. The primary outcome was a negative nucleic acid amplification test for rectal chlamydia (microbiologic cure) at 4 weeks. Results: From August 2016 through August 2019, we enrolled 625 men (314 in the doxycycline group and 311 in the azithromycin group). Primary outcome data were available for 290 men (92.4%) in the doxycycline group and 297 (95.5%) in the azithromycin group. In the modified intention-to-treat population, a microbiologic cure occurred in 281 of 290 men (96.9%; 95% confidence interval [CI], 94.9 to 98.9) in the doxycycline group and in 227 of 297 (76.4%; 95% CI, 73.8 to 79.1) in the azithromycin group, for an adjusted risk difference of 19.9 percentage points (95% CI, 14.6 to 25.3; P<0.001). Adverse events that included nausea, diarrhea, and vomiting were reported in 98 men (33.8%) in the doxycycline group and in 134 (45.1%) in the azithromycin group (risk difference, -11.3 percentage points; 95% CI, -19.5 to -3.2). Conclusions: A 7-day course of doxycycline was superior to single-dose azithromycin in the treatment of rectal chlamydia infection among men who have sex with men. (Funded by the National Health and Medical Research Council.