The parametric g-formula can be used to contrast the distribution of potential outcomes under arbitrary treatment regimes. Like g-estimation of structural nested models and inverse probability weighting of marginal structural models, the parametric g-formula can appropriately adjust for measured time-varying confounders that are affected by prior treatment. However, there have been few implementations of the parametric g-formula to date. Here, we apply the parametric g-formula to assess the impact of highly active antiretroviral therapy on time to acquired immune deficiency syndrome (AIDS) or death in two US-based human immunodeficiency virus cohorts including 1498 participants. These participants contributed approximately 7300 person-years of follow-up (49% exposed to highly active antiretroviral therapy) during which 382 events occurred and 259 participants were censored because of dropout. Using the parametric g-formula, we estimated that antiretroviral therapy substantially reduces the hazard of AIDS or death (hazard ratio = 0.55; 95% confidence limits [CL]: 0.42, 0.71). This estimate was similar to one previously reported using a marginal structural model, 0.54 (95% CL: 0.38, 0.78). The 6.5-year difference in risk of AIDS or death was 13% (95% CL: 8%, 18%). Results were robust to assumptions about temporal ordering, and extent of history modeled, for time-varying covariates. The parametric g-formula is a viable alternative to inverse probability weighting of marginal structural models and g-estimation of structural nested models for the analysis of complex longitudinal data.