Cystic fibrosis (CF) is a life-shortening disease caused by mutations in the cystic fibrosis transmembrane conductance regulator (CFTR) gene. Although bacterial lung infection and the resulting inflammation cause most of the morbidity and mortality, how the loss of CFTR function first disrupts airway host defence has remained uncertain. To investigate the abnormalities that impair elimination when a bacterium lands on the pristine surface of a newborn CF airway, we interrogated the viability of individual bacteria immobilized on solid grids and placed onto the airway surface. As a model, we studied CF pigs, which spontaneously develop hallmark features of CF lung disease. At birth, their lungs lack infection and inflammation, but have a reduced ability to eradicate bacteria. Here we show that in newborn wild-type pigs, the thin layer of airway surface liquid (ASL) rapidly kills bacteria in vivo, when removed from the lung and in primary epithelial cultures. Lack of CFTR reduces bacterial killing. We found that the ASL pH was more acidic in CF pigs, and reducing pH inhibited the antimicrobial activity of ASL. Reducing ASL pH diminished bacterial killing in wild-type pigs, and, conversely, increasing ASL pH rescued killing in CF pigs. These results directly link the initial host defence defect to the loss of CFTR, an anion channel that facilitates HCO(3)(-) transport. Without CFTR, airway epithelial HCO(3)(-) secretion is defective, the ASL pH falls and inhibits antimicrobial function, and thereby impairs the killing of bacteria that enter the newborn lung. These findings suggest that increasing ASL pH might prevent the initial infection in patients with CF, and that assaying bacterial killing could report on the benefit of therapeutic interventions.