Carbon dioxide (CO2) is the primary greenhouse gas responsible for the greenhouse effect, which traps heat in Earth's atmosphere and contributes to global warming. While other gases like methane and water vapor also contribute to the greenhouse effect, CO2 is the most significant due to its abundance and long atmospheric lifetime. Oxygen and nitrogen, which make up most of Earth's atmosphere, are not greenhouse gases.