To study the emergence and evolution of drug resistance during treatment of HIV infection, we study a mathematical model with two strains, one drug-sensitive and the other drug-resistant, by incorporating cytotoxic T lymphocyte (CTL) immune response. The reproductive numbers for each strain with and without the CTL immune response are obtained and shown to determine the stability of the steady states. By sensitivity analysis, we evaluate how the changes of parameters influence the reproductive numbers. The model shows that CTL immune response can suppress the development of drug resistance. There is a dynamic relationship between antiretroviral drug administration, the prevalence of drug resistance, the total level of viral production, and the strength of immune responses. We further investigate the scenario under which the drug-resistant strain can outcompete the wild-type strain. If drug efficacy is at an intermediate level, the drug-resistant virus is likely to arise. The slower the immune response wanes, the slower the drug-resistant strain grows. The results suggest that immunotherapy that aims to enhance immune responses, combined with antiretroviral drug treatment, may result in a functional control of HIV infection.