In first-line antiretroviral therapy (ART) for human immunodeficiency virus (HIV) treatment, some subgroups of patients may respond better to an efavirenz (EFV)-based regimen compared to an integrase strand transfer inhibitor (InSTI)-based regimen, or vice versa, due to patient characteristics modifying treatment effects. Using data based on nearly 16,000 patients from the North American AIDS Cohort Collaboration on Research and Design from 2009 to 2016, statistical methods for precision medicine were employed to estimate an optimal treatment rule that minimizes the 5-year risk of the composite outcome of AIDS-defining illnesses, serious non-AIDS events, and all-cause mortality. The treatment rules considered were functions that recommend either an EFV- or InSTI-based regimen conditional on baseline patient characteristics such as demographic information, laboratory results, and health history. The estimated 5-year risk under the estimated optimal treatment rule was 10.0% (95% confidence interval, 8.6% to 11.3%), corresponding to an absolute risk reduction of 2.3% (0.9% to 3.8%) when compared to recommending an EFV-based regimen for all patients and 2.6% (1.0% to 4.2%) when compared to recommending an InSTI-based regimen for all. Tailoring ART to individual patient characteristics may reduce 5-year risk of the composite outcome as compared to assigning all patients the same drug regimen.