Laboratory experiments show that social interactions between bacterial cells can drive evolutionary change at the population level, but significant challenges limit attempts to assess the relevance of these findings to natural populations, where selection pressures are unknown. We have increasingly sophisticated methods for monitoring phenotypic and genotypic dynamics in bacteria causing infectious disease, but in contrast, we lack evidence-based adaptive explanations for those changes. Evolutionary change during infection is often interpreted as host adaptation, but this assumption neglects to consider social dynamics shown to drive evolutionary change in vitro. We provide evidence to show that long-term behavioral dynamics observed in a pathogen are driven by selection to outcompete neighboring conspecific cells through social interactions. We find that Pseudomonas aeruginosa bacteria, causing lung infections in patients with cystic fibrosis, lose cooperative iron acquisition by siderophore production during infection. This loss could be caused by changes in iron availability in the lung, but surprisingly, we find that cells retain the ability to take up siderophores produced by conspecifics, even after they have lost the ability to synthesize siderophores. Only when cooperative producers are lost from the population is the receptor for uptake lost. This finding highlights the potential pitfalls of interpreting loss of function in pathogenic bacterial populations as evidence for trait redundancy in the host environment. More generally, we provide an example of how sequence analysis can be used to generate testable hypotheses about selection driving long-term phenotypic changes of pathogenic bacteria in situ.social evolution | infection | cooperation | cheating | cystic fibrosis