This study investigates the impact of sand contamination on the mechanical properties of railway ballasted tracks in confined condition. A combination of experimental confined uniaxial compression tests and discrete element method (DEM) simulations was employed. The experiments assessed the bulk density and elastic modulus of ballast aggregates, while the DEM simulations focused on sand movement, coordination numbers, and contact forces to elucidate the mesoscopic behavior. Findings from both experiments and simulations consistently demonstrate that sand contamination linearly increases the bulk density and causes a non-linear increase in the elastic modulus of ballast aggregates. With increasing degrees of sand contamination under vertical loading, both coordination numbers and contact forces are reduced. Sand intrusion initially leads to an uneven distribution of sand grains, primarily in the lower layer of the ballast aggregate; however, this distribution becomes more uniform when contamination exceeds 62.5%. The presence of sand particles diminishes the contact forces between ballast particles, thereby escalating the challenges associated with maintenance and repair.