Transformation of genetic material between bacteria was first observed in the 1920s using Streptococcus pneumoniae as a model organism. Since then, the mechanism of competence induction and transformation has been well characterized, mainly using planktonic bacteria or septic infection models. However, epidemiological evidence suggests that genetic exchange occurs primarily during pneumococcal nasopharyngeal carriage, which we have recently shown is associated with biofilm growth, and is associated with cocolonization with multiple strains. However, no studies to date have comprehensively investigated genetic exchange during cocolonization in vitro and in vivo or the role of the nasopharyngeal environment in these processes. In this study, we show that genetic exchange during dual-strain carriage in vivo is extremely efficient (10-2) and approximately 10,000,000-fold higher than that measured during septic infection (10-9). This high transformation efficiency was associated with environmental conditions exclusive to the nasopharynx, including the lower temperature of the nasopharynx (32 to 34°C), limited nutrient availability, and interactions with epithelial cells, which were modeled in a novel biofilm model in vitro that showed similarly high transformation efficiencies. The nasopharyngeal environmental factors, combined, were critical for biofilm formation and induced constitutive upregulation of competence genes and downregulation of capsule that promoted transformation. In addition, we show that dual-strain carriage in vivo and biofilms formed in vitro can be transformed during colonization to increase their pneumococcal fitness and also, importantly, that bacteria with lower colonization ability can be protected by strains with higher colonization efficiency, a process unrelated to genetic exchange.