The physical and mechanical properties of rocks change significantly after being subjected to high temperatures, which poses safety hazards to underground projects such as coal underground gasification. In order to investigate the effect of temperature on the macroscopic and microscopic properties of rocks, this paper has taken sandstone as the research object and conducted uniaxial compression tests on sandstone specimens at different temperatures (20–1000 °C) and different heating rates (5–30 °C/min). At the same time, the acoustic emission (AE) test system was used to observe the acoustic emission characteristics of the rock damage process, and the microstructural changes after high temperature were analyzed with the help of a scanning electron microscope (SEM). The test results show that the effect of temperature on sandstone is mainly divided into three stages: Stage I (20–500 °C) is the strengthening zone, the evaporation of water and the contraction of primary fissures, and sandstone densification is enhanced. In particular, the compressive strength and elastic modulus increase, the macroscopic damage mode is dominated by shear damage, and the fracture micromorphology is mainly brittle fracture. Stage II (500–600 °C) is the transition zone, 500 °C is the threshold temperature for the compressive strength and modulus of elasticity, and the damage mode changes from shear to cleavage damage, and the sandstone undergoes brittle–ductile transition in this temperature interval. Stage III is the physicochemical deterioration stage. The changes in the physical and chemical properties make the sandstone compressive strength and modulus of elasticity continue to decline, the macroscopic damage mode is mainly dominated by cleavage damage, and the fracture microscopic morphology is of a more toughness fracture. The effect of different heating rates on the mechanical properties of sandstone was further studied, and it was found that the mechanical properties of the rock further deteriorated under higher heating rates.