Acquired drug resistance is a major limitation for successful treatment of cancer. Resistance emerges due to drug exclusion, drug metabolism and alteration of the drug target by mutation or overexpression. Depending on therapy, the type of cancer and its stage, one or several genetic or epigenetic alterations are necessary to confer resistance to treatment. The fundamental question is the following: if a genetically diverse population of replicating cancer cells is subjected to chemotherapy that has the potential to eradicate it, what is the probability of emergence of resistance? Here, we review a general mathematical framework based on multi-type branching processes designed to study the dynamics of escape of replicating organisms from selection pressures. We apply the general model to evolution of resistance of cancer cells and discuss examples for diverse mechanisms of resistance. Our theory shows how to estimate the probability of success for any treatment regimen.