PurposeThis study establishes a method for predicting ground vibrations caused by railway tunnels in unsaturated soils with spatial variability.Design/methodology/approachFirst, an improved 2.5D finite-element-method-perfect-matching-layer (FEM-PML) model is proposed. The Galerkin method is used to derive the finite element expression in the ub-pl-pg format for unsaturated soil. Unlike the ub-v-w format, which has nine degrees of freedom per node, the ub-pl-pg format has only five degrees of freedom per node; this significantly enhances the calculation efficiency. The stretching function of the PML is adopted to handle the unlimited boundary domain. Additionally, the 2.5D FEM-PML model couples the tunnel, vehicle and track structures. Next, the spatial variability of the soil parameters is simulated by random fields using the Monte Carlo method. By incorporating random fields of soil parameters into the 2.5D FEM-PML model, the effect of soil spatial variability on ground vibrations is demonstrated using a case study.FindingsThe spatial variability of the soil parameters primarily affected the vibration acceleration amplitude but had a minor effect on its spatial distribution and attenuation over time. In addition, ground vibration acceleration was more affected by the spatial variability of the soil bulk modulus of compressibility than by that of saturation.Originality/valueUsing the 2.5D FEM-PML model in the ub-pl-pg format of unsaturated soil enhances the computational efficiency. On this basis, with the random fields established by Monte Carlo simulation, the model can calculate the reliability of soil dynamics, which was rarely considered by previous models.