Simian immunodeficiency viruses (SIVs) comprise a large group of primate lentiviruses that endemically infect African monkeys. HIV-1 spilled over to humans from this viral reservoir, but the spillover did not occur directly from monkeys to humans. Instead, a key event was the introduction of SIVs into great apes, which then set the stage for infection of humans. Here, we investigate the role of the lentiviral entry receptor, CD4, in this key and fateful event in the history of SIV/HIV emergence. First, we reconstructed and tested ancient forms of CD4 at two important nodes in ape speciation, prior to the infection of chimpanzees and gorillas with these viruses. These ancestral CD4s fully supported entry of diverse SIV isolates related to the virus(es) that made this initial jump to apes. In stark contrast, modern chimpanzee and gorilla CD4s are more resistant to these viruses. To investigate how this resistance in CD4 was gained, we acquired CD4 sequences from 32 gorilla individuals of 2 species, and identified alleles that encode 8 unique CD4 proteins. Function testing of these identified allele-specific CD4 differences in susceptibility to virus entry. By engineering single point mutations from gorilla CD4 alleles into a permissive human CD4 receptor, we demonstrate that acquired SNPs in gorilla CD4 did convey resistance to virus entry. We provide a population genetic analysis to support the theory that selection is acting in favor of more and more resistant CD4 alleles in apes with endemic SIV infection (gorillas and chimpanzees), but not in other ape species (bonobo and orangutan) that lack SIV infections. Taken together, our results show that SIV has placed intense selective pressure on ape CD4, acting to drive the generation of SIV-resistant CD4 alleles in chimpanzees and gorillas.