It is a well known fact that in stars, there exists a temperature gradiënt. The observational reason is because we perceived spectral lines in the otherwise continuous spectrum of a star. If this wasn't the case, and thus if the temperature were uniform, then the absorption and the emission would cancel each other out and we would observe a net effect that results in a continuous spectrum. Now my question is: what is the physical explanation for this temperature gradient?

You're talking about the temperature gradients in the atmosphere of a star, that's where the emission and absorption lines are originating. This is a much more complicated matter than the star itself.

The temperature of a star must increase from its surface downwards.
This is a simple result of the fact that the stellar structure is given by pressure gradients balancing the force of gravity. We can express this via the law of hydrostatic equilibrium
$$\frac{\partial P}{\partial r} = -g(r)\rho$$ which is a pretty good approximation to reality in most cases.

The pressure gradient then translates into a temperature gradient, as the pressure originates in the thermal motion of particles, formalized as the law of ideal gases
$$P = \frac{\rho k_B T}{\mu}$$.

So wherever there's non-zero gravity and no other force in a gaseous medium, there will be temperature gradients.

In an atmosphere, things depend on how efficient the gas is at cooling. In very thin media, like in Earths or any planets / stars exosphere cooling is inefficient enough to make temperature gradients vanish.

• I don't think this fully answers the question. It explains why the product $\rho T \mu^{-1}$ becomes smaller with radius, but not why both $\rho$ and $T$ do so individually. – ProfRob Sep 2 '18 at 15:53
• @RobJeffries: True, but as OP is a new contributor I didn't know the level of detail expected, so I chose to write a simple answer and to leave out energy transport. – AtmosphericPrisonEscape Sep 2 '18 at 16:07
• Well for instance, the temperature of the Sun's atmosphere increases considerably above the photosphere, despite the pressure decreasing. The answer is not just hydrostatic equilibrium. – ProfRob Sep 2 '18 at 17:59
• @RobJeffries: That's of course true. But OP asked for the explanation of any temperature gradient, and this seemed like a very simple one, one that a first year physics student could understand. Also no mention of the sign of the gradient was provided. – AtmosphericPrisonEscape Sep 2 '18 at 19:06
• Your explanation would have it that the temperature gradient can only be negative, since the pressure gradient can only be negative for an object in hydrostatic equilibrium. I pointed out that the temperature gradient can be positive in some regions to illustrate that your explanation of the reason for a temperature gradient is incomplete. In this case the OP seems to be talking about the negative temperature gradient in the photosphere, since this is responsible for absorption lines. – ProfRob Sep 2 '18 at 19:38

Force balance only tells you that the pressure must decrease outward, the cause of the decreasing temperature is the nature of heat transport and the requirement that it increase entropy. Hence heat is always transported from higher T to lower T, and a star must transport heat outward because its surface is losing heat to the coldness of space. That requires the temperature must drop as you go out, as long as you are just passing the same heat from layer to layer and the thermodynamics of heat transport rules the situation.

It was pointed out that the low-density atmospheres of stars can have their temperature rise with height, as the Earth's stratosphere also does, yet the net energy transport is still outward. To avoid entropy decrease, this requires that more heat be deposited in the hot layers than is extracted from the cooler ones below, so the heat dumped high up in the atmosphere has to come from somewhere else, other than the cool layers. That's what can't happen deep in the star-- the heat gets no "Free ride" to pass certain layers, it is passed from layer to layer, the same heat. But when there are ways to dump heat into higher layers without extracting it from cooler ones below, then the temperature can rise. (In the Earth's stratosphere, the extra heat comes from sunlight absorbed by ozone, and in the Sun's chromosphere, the extra heat comes from magnetic fields and plasma motions, which pass through the lower layers without being absorbed.)