Microbial symbionts account for survival, development, fitness and evolution of eukaryotic hosts. These microorganisms together with their host form a biological unit known as holobiont. Recent studies have revealed that the holobiont of agaves and cacti comprises a diverse and structured microbiome, which might be important for its adaptation to drylands. Here, we investigated the functional signatures of the prokaryotic communities of the soil and the episphere, that includes the rhizosphere and phyllosphere, associated with the cultivated Agave tequilana and the native and sympatric Agave salmiana, Opuntia robusta and Myrtillocactus geometrizans by mining shotgun metagenomic data. Consistent with previous phylogenetic profiling, we found that Proteobacteria, Actinobacteria and Firmicutes were the main represented phyla in the episphere of agaves and cacti, and that clustering of metagenomes correlated with the plant compartment. In native plants, genes related to aerobic anoxygenic phototrophy and photosynthesis were enriched in the phyllosphere and soil, while genes coding for biofilm formation and quorum sensing were enriched in both epiphytic communities. In the episphere of cultivated A. tequilana fewer genes were identified, but they belonged to similar pathways than those found in native plants. A. tequilana showed a depletion in several genes belonging to carbon metabolism, secondary metabolite biosynthesis and xenobiotic degradation suggesting that its lower microbial diversity might be linked to functional losses. However, this species also showed an enrichment in biofilm and quorum sensing in the epiphytic compartments, and evidence for nitrogen fixation in the rhizosphere. Aerobic anoxygenic phototrophic markers were represented by Rhizobiales (Methylobacterium) and Rhodospirillales (Belnapia) in the phyllosphere, while photosystem genes were widespread in Bacillales and Cyanobacteria. Nitrogen fixation and biofilm formation genes were mostly related to Proteobacteria. These analyses support the idea of niche differentiation in the rhizosphere and phyllosphere of agaves and cacti and shed light on the potential mechanisms by which epiphytic microbial communities survive and colonize plants of arid and semiarid ecosystems. This study establishes a guideline for testing the relevance of the identified functional traits on the microbial community and the plant fitness