The CFTR gene encodes a transmembrane conductance regulator, which is dysfunctional in patients with cystic fibrosis (CF). The mechanism by which defective CFTR (CF transmembrane conductance regulator) leads to undersialylation of plasma membrane glycoconjugates, which in turn promote lung pathology and colonization with Pseudomonas aeruginosa causing lethal bacterial infections in CF, is not known. Here we show by ratiometric imaging with lumenally exposed pH-sensitive green fluorescent protein that dysfunctional CFTR leads to hyperacidification of the trans-Golgi network (TGN) in CF lung epithelial cells. The hyperacidification of TGN, glycosylation defect of plasma membrane glycoconjugates, and increased P. aeruginosa adherence were corrected by incubating CF respiratory epithelial cells with weak bases. Studies with pharmacological agents indicated a role for sodium conductance, modulated by CFTR regulatory function, in determining the pH of TGN. These studies demonstrate the molecular basis for defective glycosylation of lung epithelial cells and bacterial pathogenesis in CF, and suggest a cure by normalizing the pH of intracellular compartments.