Atmospheric temperature information in the near space is of great academic significance and engineering value to support the development and utilization of the near space. Based on the theory of O2 molecular dayglow spectroscopy and the mechanism of atmospheric radiative transfer, a method is proposed for the joint retrieval of temperature profiles in the near space using O2(a1Δg) and O2(b1∑+g) bands dayglow spectroscopy signal with the self-absorption effect. First, the temperature dependence of O2(a1Δg) and O2(b1∑+g) bands dayglow is investigated, and the influence of the self-absorption effect on the radiative transfer characteristics is analyzed in the limb-view mode. Then, with the use of the onion peeling algorithm, the dayglow emission spectra signals of the O2(a1Δg) and O2(b1∑+g) bands measured by the SCanning Imaging Absorption spectroMeter for Atmospheric CHartographY (SCIAMACHY) in the limb-viewing mode were processed, and combined with optimization algorithms, the temperature profiles from 35 km to 120 km is successfully retrieved. Finally, the accuracy and reliability of the self-absorption effect correction as well as the joint temperature retrieval were verified by comparing with temperature product data from remote sensing satellites such as Sounding of the Atmosphere using Broadband Emission Radiometry (SABER), Atmospheric Chemistry Experiment Fourier-Transform Spectrometer (ACE-FTS), and Michelson Interferometer for Passive Atmospheric Sounding (MIPAS). The error analysis shows that the temperature retrieval error after correction for the self-absorption effect is about 3 K minimum and 20 K maximum.