Evidence on the effectiveness of highly active antiretroviral therapy (HAART) for HIV-infected individuals is limited. Most clinical trials examined surrogate endpoints over short periods of follow-up and there has been no placebo-controlled randomised trial of HAART. Estimation of treatment effects in observational studies is problematic, because of confounding by indication. We aimed to use novel methodology to overcome this problem in the Swiss HIV Cohort Study. Patients were included if they had been examined after January 1996, when HAART became available in Switzerland, were not on HAART, and were free of AIDS at baseline. Cox regression models were weighted to create a statistical population in which the probability of being treated at each time point was unrelated to prognostic factors. Low CD4 counts and increasing HIV-1 viral load were associated with increased probability of starting HAART. Overall hazard ratios were 0.14 (95% CI 0.07-0.29) for HAART compared with no treatment, and 0.49 (0.31-0.79) compared with dual therapy. Compared with no treatment, HAART became more beneficial with increasing time since initiation but was less beneficial for patients whose presumed mode of transmission was via intravenous drug use (hazard ratio 0.27, 0.12-0.61) than for other patients (0.08, 0.03-0.19). Our results, which are appropriately controlled for confounding by indication, are consistent with reported declines in rates of AIDS and death in developed countries, and provide a context in which to consider adverse effects of HAART.