During underground resource extraction and deep underground engineering development, the engineering rock body frequently encounters elevated temperatures and water cooling, leading to alterations in the mechanical properties of the rock. These changes will have an impact on the safety and stability of the project. This study aimed to investigate the changes in mechanical properties of rocks following treatment with high temperatures and water cooling. The experiment involved subjecting layered sandstone samples to heating and water cooling, followed by conducting uniaxial compression tests using a high-temperature furnace and a WA-1000 universal testing machine. The effects of temperature and inclination angles on the uniaxial mechanical properties of layered sandstone were then analyzed. Furthermore, the utilization of the scanning electron microscope and various other microscopic testing devices allowed for the examination of the micro-mechanism behind rock damage and rupture subsequent to undergoing heating and water-cooling treatment. The findings from the experiment suggest that: 1) the relationship between the changes in sandstones’ mechanical properties and temperature and bedding inclinations can be attributed to the uneven deformation of minerals caused by heating and water-cooling treatment, leading to the distribution of microcracks within the rock. 2) The stress-strain curve of the specimen can be divided as four-stages. With the increase of bedding inclination, the compaction stage of the specimen is more prominent. 3) As the bedding inclination increases, the specimens exhibit a pattern of initially decreasing and then increasing in terms of peak strength and strain. With the increase of temperature, the peak axial strain gradually increases, while it first increases and then decreases with the increasing dip angles.