Bacteria commonly protect themselves by forming multicellular structures called biofilms. The opportunistic pathogen Pseudomonas aeruginosa causes antibiotic-recalcitrant pneumonia by forming biofilms in the respiratory tract. Despite extensive in vitro experimentation, how P. aeruginosa forms biofilms at the airway mucosal surface is unresolved. We investigated P. aeruginosa biofilm biogenesis in optically-accessible tissue-engineered human lung models that emulate the airway mucosal environment. We found that P. aeruginosa forms mucus-associated biofilms within hours, much faster than previously observed in in vitro experiments. Early during colonization, P. aeruginosa induces contractions of luminal mucus which accelerates bacterial aggregation. We show that P. aeruginosa uses retractile type IV pili to actively compress mucus. Our results suggest that, while protecting epithelia, mucus constitutes a breeding ground for biofilms.