We use mathematical models to study the relationship between HIV and the immune system during the natural course of infection and in the context of different antiviral treatment regimes. The models suggest that an efficient cytotoxic T lymphocyte (CTL) memory response is required to control the virus. We define CTL memory as long-term persistence of CTL precursors in the absence of antigen. Infection and depletion of CD4(+) T helper cells interfere with CTL memory generation, resulting in persistent viral replication and disease progression. We find that antiviral drug therapy during primary infection can enable the development of CTL memory. In chronically infected patients, specific treatment schedules, either including deliberate drug holidays or antigenic boosts of the immune system, can lead to a re-establishment of CTL memory. Whether such treatment regimes would lead to long-term immunologic control deserves investigation under carefully controlled conditions.