The underlying assembly processes of surface microbial communities are crucial for host plants and ecosystem functions. However, the relative importance of stochastic and deterministic processes in shaping epiphytic microbes remains poorly understood in both the phyllosphere and rhizosphere. Here, we compared the spatial variations in epiphytic microbial communities of two dominant grasses along a 1400 km transect on the Tibetan Plateau and assessed the assembly processes between the phyllosphere and rhizosphere. We found significant variations in epiphytic microbial community compositions between plant compartments and host species. Stochastic processes (drift and homogenizing dispersal) predominantly shaped microbial communities in both the phyllosphere and rhizosphere, with a greater contribution of stochastic processes in the phyllosphere. As environmental heterogeneity intensified, we found a transition from stochasticity to determinism in affecting the microbial assembly. This transition to homogeneous or variable selection depended on plant compartments and host species. Our study is among the first to compare the contribution of stochastic versus deterministic processes to epiphytic community assembly between the phyllosphere and rhizosphere on the Tibetan Plateau. These findings advance our knowledge of epiphytic microbial assembly and disentangle how host plants exploit the microbiome for improved performance and functioning in stressful alpine ecosystems.