Critical illness can disrupt the composition and function of the microbiome, yet comprehensive longitudinal studies are lacking. We conducted a longitudinal analysis of oral, lung, and gut microbiota in a large cohort of 479 mechanically ventilated patients with acute respiratory failure. Progressive dysbiosis emerged in all three body compartments, characterized by reduced alpha diversity, depletion of obligate anaerobe bacteria, and pathogen enrichment. Clinical variables, including chronic obstructive pulmonary disease, immunosuppression, and antibiotic exposure, shaped dysbiosis. Notably, of the three body compartments, unsupervised clusters of lung microbiota diversity and composition independently predicted survival, transcending clinical predictors, organ dysfunction severity, and host-response sub-phenotypes. These independent associations of lung microbiota may serve as valuable biomarkers for prognostication and treatment decisions in critically ill patients. Insights into the dynamics of the microbiome during critical illness highlight the potential for microbiota-targeted interventions in precision medicine.