The oral and upper respiratory tracts are closely linked anatomically and physiologically with the lower respiratory tract and lungs, and the influence of oral and upper respiratory microbes on the lung microbiota is increasingly being recognized. However, the ecological process and individual heterogeneity of the oral and upper respiratory tract microbes shaping the lung microbiota remain unclear owing to the lack of controlled analyses with sufficient sample sizes. Here, the microbiomes of saliva, nasal cavity, oropharyngeal area, and bronchoalveolar lavage samples are profiled and the shaping process of multisource microbes on the lung microbiota is measured. It is found that oral and nasal microbial inputs jointly shape the lung microbiota by occupying different ecological niches. It is also observed that the spread of oral microbes to the lungs is heterogeneous, with more oral microbes entering the lungs being associated with decreased lung function and increased lung proinflammatory cytokines. These results depict the external shaping process of lung microbiota and indicate the great value of oral samples, such as saliva, in monitoring and assessing lung microbiota status in clinical settings.