Immunocompromised hosts are highly vulnerable to lung infections, but the efficacy of traditional diagnosis is unsatisfactory. Metagenomic next-generation sequencing (mNGS) has high throughput and broad coverage. Its value in different types of immunocompromised patients has yet to be fully explored. Therefore, the study aims to evaluate the value of mNGS in immunocompromised patients. Clinical data from immunocompromised patients with suspected pulmonary infection (PI) (September 2018-2021) were retrospectively analysed. Patients were categorised into PI (87 cases) and non-pulmonary infection (NPI, 14 cases) groups. The diagnostic performance between mNGS and conventional microbiological tests (CMTs) was compared. Subgroup analyses were also conducted based on whether the patients received organ transplantation, including the comparison of the diagnostic performance of mNGS and culture and the spectrum of characteristics among them. mNGS demonstrated significantly elevated diagnostic sensitivity (p < 0.001) over traditional methods, with a pronounced advantage in identifying mixed PIs (p < 0.05). Among immunocompromised cohorts, mNGS outperformed cultures, showing higher positivity rates in both organ transplant (p < 0.001) and non-transplant patients (p < 0.001). Mixed infections, predominantly bacterial-fungal, were more prevalent in transplant recipients with reduced lymphocytes and CD4+ T cells. Pathogen profiles differed, with Pneumocystis jirovecii, Cytomegalovirus, and Pseudomonas aeruginosa predominating in organ transplant recipients, and P. jirovecii, P. aeruginosa, Streptococcus pneumoniae and Streptococcus pallidum in non-transplant individuals. mNGS is valuable in diagnosing PI and mixed infections in immunocompromised patients, which may be particularly suitable for identifying mixed infections in patients with organ transplants and low lymphocyte and CD4+ T lymphocyte counts.