This question has been bothering me for many years and maybe I've been too embarassed to ask up until now. The reason why a thin atomic gas has an absorption spectrum has been explained to me by noting that the atoms absorb certain frequencies only and reemit the absorbed radiation in all directions. This explaines the effect for the usual experimental setup.
However, I think the sun's spectral lines cannot be explained in this way. Assuming the direction of reemission is random would mean that most of the solid angle from an atom in the sun's atmosphere would be facing outwards. This would lead one to expect the intensity at the absorption lines to be only slightly weaker, while the lines are in reality quite pronounced. What mechanism explains this behaviour?
Also what would be the emission spectrum of a thin atomic gas in thermal equilibrium? Would it have spectral lines?