The HIV evolutionary processes continuously unfold, leaving a measurable footprint in viral gene sequences. A variety of statistical models and inference techniques have been developed to reconstruct the HIV evolutionary history and to investigate the population genetic processes that shape viral diversity. Remarkably different population genetic forces are at work within and among hosts. Population-level HIV phylogenies are mainly shaped by selectively neutral epidemiologic processes, implying that genealogy-based population genetic inference can be useful to study the HIV epidemic history. Such evolutionary analyses have shed light on the origins of HIV, and on the epidemic spread of viral variants in different geographic locations and in different populations. The HIV genealogies reconstructed from within-host sequences indicate the action of selection pressure. In addition, recombination has a significant impact on HIV genetic diversity. Accurately quantifying both the adaptation rate and the population recombination rate of HIV will contribute to a better understanding of immune escape and drug resistance. Characterizing the impact of HIV transmission on viral genetic diversity will be a key factor in reconciling the different population genetic processes within and among hosts.