Eligibility Criteria:
Inclusion Criteria for Step 1:
* HIV-1 infection, documented by any licensed rapid HIV test or HIV enzyme or chemiluminescence immunoassay (E/CIA) test kit at any time prior to study entry and confirmed by a licensed Western blot or a second antibody test by a method other than the initial rapid HIV and/or E/CIA, or by HIV-1 antigen, plasma HIV-1 RNA VL.
* Any previous combination of ARV treatment at any time with at least one regimen that contained one NNRTI and two NRTIs which was replaced with a PI-based regimen because of virologic, immunologic, or clinical treatment failure, or because of toxicity.
NOTE: All potential participants with prior RAL exposure were assigned to either Cohort A or Cohort D.
* At screening, receipt of a PI-based regimen with no regimen change for a minimum of 24 weeks prior to screening.
* Confirmation of VF of current second-line PI-based ART. NOTE A: Failure of the current second-line regimen was defined as two consecutive measurements of plasma HIV-1 RNA ≥1000 copies/mL obtained at least 1 day apart while on the current PI-based regimen. "Current PI-based regimen" and "current regimen" were understood to be the regimen described (ie, the regimen that the candidate was taking when the first VF sample was drawn plus only those modifications allowed).
* CD4+ T-cell count result from a specimen drawn within 103 days prior to study entry
* Laboratory values obtained within 30 days prior to study entry:
* Absolute neutrophil count (ANC) ≥ 500/mm\^3
* Hemoglobin ≥7.5 g/dL
* Platelet count ≥40,000/mm\^3
* Creatinine ≤2 X upper limit of normal (ULN)
* Aspartate aminotransferase (AST), serum glutamic oxaloacetic transaminase (SGOT), alanine aminotransferase (ALT), serum glutamic pyruvic transaminase (SGPT), and alkaline phosphatase ≤5 x ULN
* Total bilirubin ≤2.5 x ULN
* Creatinine clearance (CrCl) \>30 mL/min, either measured or estimated by Cockcroft-Gault equation
* Hepatitis B panel that includes HbsAB, HBcAB, and HBsAG or only HBsAG, with plasma stored for later anti-HBs and anti-HBc.
NOTE A: Candidates who were eligible for cohort B and who were positive for active hepatitis B infection were assigned to sub-cohort B3 at registration/randomization.
NOTE B: Candidates with CrCl \<60 mL/min who were also positive for active hepatitis B infection were not eligible.
* Females of reproductive potential (women who have not been post-menopausal for at least 24 consecutive months, ie, who have had menses within the preceding 24 months, or women who have not undergone surgical sterilization, hysterectomy or bilateral salpingectomy or bilateral oophorectomy or tubal ligation) must have had a negative serum or urine pregnancy test prior to the submission of the screening genotype testing sample and again within 48 hours prior to randomization or registration.
* Female participants of reproductive potential must have agreed not to participate in the conception process (ie, active attempt to become pregnant, in vitro fertilization), and if participating in sexual activity that could lead to pregnancy, the female participant must have used at least one reliable form of contraceptive. Female participants must have continued to use contraceptives while receiving study treatment and for 6 weeks after stopping study treatment.
Acceptable forms of contraceptives included:
* Condoms (male or female) with or without a spermicidal agent
* Diaphragm or cervical cap with spermicide
* Intrauterine device (IUD)
* Hormonal contraception
Female participants who were not of reproductive potential or whose male partner(s) had documented azoospermia) were not required to use contraceptives. Any statement of self-reported sterility or that of her partner's must have been entered in the source documents.
NOTE: Acceptable documentation of lack of reproductive potential was oral or written documentation from the participant.
* Karnofsky performance score \>/= 70 within 30 days prior to study entry.
* Ability and willingness of potential participant to provide informed consent.
* Willingness of potential participant to adhere to protocol requirements, especially with respect to treatment assignment and ability to obtain non-study provided ART, if needed.
* Ability to take oral study medications.
* No intention of permanent relocation that would preclude attending Step 1 and 2 study follow-up visits.
* Availability of a successful, interpretable resistance genotype report from a DAIDS-approved regional genotyping facility from testing performed on a plasma sample that was collected during screening (ie, at or after the date that a sample is collected to confirm HIV-1 virologic failure) and which was shipped to a regional resistance testing laboratory once documentation of two screening plasma HIV-1 RNA values ≥1000 copies/mL were available.
* Identification of a cohort assignment and ARV regimen for use on study, selected from the recommended options provided by the site investigator, and reviewed and approved by the A5288 Clinical Management Committee (CMC).
Exclusion Criteria for Step 1:
* Pregnancy or breast-feeding.
* Known allergy/sensitivity or any hypersensitivity to components of study drugs or their formulation.
* Active drug or alcohol use or dependence that, in the opinion of the site investigator, would have interfered with adherence to study requirements.
* Serious illness requiring systemic treatment and/or hospitalization until candidate either completes therapy or was clinically stable on therapy, in the opinion of the site investigator, for at least 7 days prior to study entry.
* Concurrent illness or condition that would compromise the ability to take study medication, follow the protocol, or that would make participation not in the best interest of the participant, per the site investigator.
* Requirement for taking any of the prohibited medications with the selected ARV study regimen, or within 14 days prior to study entry.
NOTE: Study candidates should not have discontinued any component of their ART during screening. The 14-day restriction on prohibited medications did not apply to ARVs.
* Active tuberculosis (TB) or rifampin exposure less than 2 weeks prior to study entry.
* Any exposure to darunavir or etravirine.