Drug resistance remains a major problem for the treatment of HIV. Resistance can occur due to mutations that were present before treatment starts or due to mutations that occur during treatment. The relative importance of these two sources is unknown. We study three different situations in which HIV drug resistance may evolve: starting triple-drug therapy, treatment with a single dose of nevirapine and interruption of treatment. For each of these three cases good data are available from literature, which allows us to estimate the probability that resistance evolves from standing genetic variation. Depending on the treatment we find probabilities of the evolution of drug resistance due to standing genetic variation between 0 and 39%. For patients who start triple-drug combination therapy, we find that drug resistance evolves from standing genetic variation in approximately 6% of the patients. We use a population-dynamic and population-genetic model to understand the observations and to estimate important evolutionary parameters. We find that both, the effective population size of the virus before treatment, and the fitness of the resistant mutant during treatment, are key-parameters that determine the probability that resistance evolves from standing genetic variation. Importantly, clinical data indicate that both of these parameters can be manipulated by the kind of treatment that is used.