Let's look at what really happens to sunlight when it reaches Earth. Now, let's look at what happens to the light absorbed by the ground. The ground cleary must warm up. Warm things radiate heat to cool off, so the ground gives energy in the form of infrared light. Water is not the only good molecule for absorbing infrared light.
Carbon dioxide is also an excellent absorber.
Between the H 2 O and CO 2 nearly all the upward going infrared light is absorbed in the atmosphere. Now we have to think about the atmosphere. It also is heated up, both by sunlight from above and infrared light from below. Thus, the atmosphere has to give off heat. Let's revisit our scenario from above.