Greenhouse gases (GHGs) in dense air near the surface intercept most of the thermal radiation emitted by the warm surface. GHGs in sparse air at higher elevations emit thermal radiation to space, at a lower rate than surface emissions, due to the lower temperature. The temperatures at different elevations are connected via the environmental lapse rate. The surface is about 33℃ (59℉) warmer than the temperature needed to emit enough radiation to balance absorbed sunlight.
The key principle in play is that planetary temperature is determined by radiative equilibrium. In steady-state, a planet must balance the rate of thermal energy it is receiving from received sunlight (possibly supplemented by internal energy sources, in the case of certain celestial bodies) by emitting infrared thermal radiation to space at an equal rate. Greenhouse gases are gases that have the ability to absorb and emit that radiation. Their presence interferes with thermal radiation from the surface directly reaching space.
The resulting temperature rise can be understood in either of two ways:

Because the efficiency of planetary cooling is reduced, the surface needs to be at a higher temperature in order for enough thermal radiation to reach space, compared with the surface temperature that would suffice if there were no greenhouse gases.
The thermal radiation that reaches space can be understood as mostly being emitted around an altitude where the air temperature leads to the rate of thermal emissions being able to balance the rate at which the planet is receiving heat. Because the surface is lower, it will be warmer, because convection causes upward-moving air to cool and downward-moving air to warm. Thus, because the "effective emission height" for thermal radiation is at a significant altitude, the surface will be significantly warmer.These two ways of understanding the effect are largely equivalent. The first formulation is easier to formulate in a totally rigorous fashion, and is the one most commonly used by scientists. Some people find the second explanation to be more intuitively understandable.
References
Similar figures

https://greatwhitecon.info/wp-content/uploads/2016/02/benestad-ghe.gif
https://www.aos.wisc.edu/~aos121br/radn/radn/sld015.htm
https://www.youtube.com/watch?v=8Ukxv5-pwlg&amp;t=1844s
https://www.annualreviews.org/doi/10.1146/annurev.energy.25.1.441Background

The following article by Prof. Pierrehumbert, shows that there is an emission temperature and altitude for each wavelength in the outgoing IR spectrum (see Fig. 3)https://geosci.uchicago.edu/~rtp1/papers/PhysTodayRT2011.pdf
The following journal article by Rasmus Benestad argues for simplifying the above, for pedagogic purposes, to thinking of the atmosphere as radiating from a single ’equivalent bulk emission level’. This is calculated from the overall “emission temperature” Te ≈ 254K characteristic of outgoing longwave radiation (which balances incoming absorbed sunlight of 240 W/m^2). The ’equivalent bulk emission level’ is the altitude at which the atmospheric temperature corresponds to Te. This level was found to be about  7.2 km, and to be increasing as greenhouse gas concentrations have increased. https://link.springer.com/article/10.1007/s00704-016-1732-y
Benetstad offered this animated figure to illustrate his concept https://greatwhitecon.info/wp-content/uploads/2016/02/benestad-ghe.gif
A slide show from University of Wisconsin shows a similar figure https://www.aos.wisc.edu/~aos121br/radn/radn/sld015.htm (see also slide 18 and 19 for what happens when CO2 concentration increases) Slide 12 defines the “effective radiating level”
This video (at timestamp 30:44) shows a similar figure, complete with temperature labels and a labeled lapse rate. (A few minutes later it shows what happens when CO2 increases.) https://www.youtube.com/watch?v=8Ukxv5-pwlg&amp;t=1844s
Physicist Sabine Hoffstader’s video (7:10 to 8:55) talks about IR being absorbed at low altitudes, then being able to escape to space at an altitude where the air gets thin enough: https://www.youtube.com/watch?v=oqu5DjzOBF8&amp;t=430s
The book "Principles of Planetary Climate" by Raymond T. Pierrehumbert, Cambridge University Press, 2010, offers additional details.
Own work
Robert Wentworth