In healthy plants, the innate immune system contributes to maintenance of microbiota homoeostasis, while disease can be associated with microbiome perturbation or dysbiosis, and enrichment of opportunistic plant pathogens like Xanthomonas. It is currently unclear whether the microbiota change occurs independently of the opportunistic pathogens or is caused by the latter. Here we tested if protein export through the type-2 secretion system (T2SS) by Xanthomonas causes microbiome dysbiosis in Arabidopsis thaliana in immunocompromised plants. We found that Xanthomonas strains secrete a cocktail of plant cell wall-degrading enzymes that promote Xanthomonas growth during infection. Disease severity and leaf tissue degradation were increased in A. thaliana mutants lacking the NADPH oxidase RBOHD. Experiments with gnotobiotic plants, synthetic bacterial communities and wild-type or T2SS-mutant Xanthomonas revealed that virulence and leaf microbiome composition are controlled by the T2SS. Overall, a compromised immune system in plants can enrich opportunistic pathogens, which damage leaf tissues and ultimately cause microbiome dysbiosis by facilitating growth of specific commensal bacteria.