Background: Efavirenz and lopinavir boosted with ritonavir are both recommended as first-line therapies for patients with HIV when combined with two nucleoside reverse transcriptase inhibitors. It is uncertain which therapy is more effective for patients starting therapy with an advanced infection.Methods: We estimated the relative effect of these two therapies on rates of virological and immunological failure within the Swiss HIV Cohort Study and considered whether estimates depended on the CD4(+) T-cell count when starting therapy. We defined virological failure as either an incomplete virological response or viral rebound after viral suppression and immunological failure as failure to achieve an expected CD4(+) T-cell increase calculated from EuroSIDA statistics.Results: Patients starting efavirenz (n=660) and lopinavir (n=541) were followed for a median of 4.5 and 3.1 years, respectively. Virological failure was less likely for patients on efavirenz, with the adjusted hazard ratio (95% confidence interval) of 0.63 (0.50-0.78) then multiplied by a factor of 1.00 (0.90-1.12) for each 100 cells/mm(3) decrease in CD4(+) T-cell count below the mean when starting therapy. Immunological failure was also less likely for patients on efavirenz, with the adjusted hazard ratio of 0.68 (0.51-0.91) then multiplied by a factor of 1.29 (1.14-1.46) for each 100 cells/mm(3) decrease in CD4(+) T-cell count below the mean when starting therapy.Conclusions: Virological failure is less likely with efavirenz regardless of the CD4(+) T-cell count when starting therapy. Immunological failure is also less likely with efavirenz; however, this advantage disappears if patients start therapy with a low CD4(+) T-cell count.