The energy that warms Earth’s lower atmosphere comes from the Sun, but sunlight does not warm the lower atmosphere directly. This region of the atmosphere warms from below. Most of the short wavelength, electromagnetic energy from the Sun passes through the atmosphere and is absorbed by the Earth, which warms up as a result. As the Earth warms, it emits some long-wave radiation back out, heating up the lower atmosphere above it. Eventually, this energy radiates from the atmosphere back into space.
The Earth does not absorb all of the electromagnetic energy that hits it. Some reflects back out into space. This is important for the Earth’s energy balance, because only absorbed energy contributes to the temperature of the Earth/atmosphere system. The proportion of the total energy reflected by the Earth (or any object) is called the Albedo.