Biofilms are structured communities of bacterial cells enclosed in a self-produced extracellular matrix. In the pathogen Staphylococcus aureus, this can enhance resistance to antibiotics and immune responses, contributing significantly to chronic infections associated with medical devices. The underlying mechanisms include the production of polysaccharide intercellular adhesin (PIA), encoded by the icaADBC operon, and surface proteins that mediate adhesion. However, it has been challenging to translate in vitro understanding to explain the molecular mechanisms governing biofilm formation in vivo. Here we combined functional and comparative genomics approaches to investigate genetic factors influencing biofilm formation in isolates belonging to the clinically important ST-8 clonal complex (CC8). Phenotypic and genomic screening of a closely related strain cohort (MRSA USA300 isolates) revealed considerable variability in biofilm formation. Genome-wide association studies (GWAS) identified several genes and polymorphisms linked to biofilm development. These included known biofilm genes and compensatory mutations that restored wild-type biofilm levels in hyper-biofilm forming mucoid isolates. Finally, contextualizing CC8 genomes within diverse S. aureus populations revealed the natural occurrence of biofilm-associated genomic variation as well as evidence for the conservation of the ica loci in CC8. This offers insight into the mechanisms and microevolutionary events that give rise to clinically relevant staphylococcal infections.