Although the darwinian concept of adaptation was established nearly a century ago, it has been difficult to demonstrate rigorously that the amino-acid differences between homologous proteins from different species have adaptive significance. There are currently two major types of sequence tests for positive darwinian selection on proteins from different species: sequence convergence, and neutral rate violation (reviewed in ref. 1). Lysozymes from the stomachs of cows and langur monkeys, two mammalian species displaying fermentation in the foregut, are an example of amino-acid sequence convergence among homologous proteins. Here we combine tests of neutral rate violation with reconstruction of ancestral sequences to document an episode of positive selection on the lineage leading to the common ancestor of the foregut-fermenting colobine monkeys. This analysis also detected a previously unsuspected adaptive episode on the lineage leading to the common ancestor of the modern hominoid lysozymes. Both adaptive episodes were followed by episodes of negative selection. Thus this approach can detect adaptive and purifying episodes, and localize them to specific lineages during protein evolution.