Antibiotic resistance poses a global health threat, but the within-host drivers of resistance remain poorly understood. Pathogen populations are often assumed to be clonal within hosts, and resistance is thought to emerge due to selection for de novo variants. Here we show that mixed strain populations are common in the opportunistic pathogenP. aeruginosa. Crucially, resistance evolves rapidly in patients colonized by multiple strains through selection for pre-existing resistant strains. In contrast, resistance evolves sporadically in patients colonized by single strains due to selection for novel resistance mutations. However, strong trade-offs between resistance and growth rate occur in mixed strain populations, suggesting that within-host diversity can also drive the loss of resistance in the absence of antibiotic treatment. In summary, we show that the within-host diversity of pathogen populations plays a key role in shaping the emergence of resistance in response to treatment.