A growing population, technological progress and economic development result in a constant increase in energy demand. Energy is mostly obtained from fossil energy resources such as coal, natural gas, and crude oil. Burning them leads to air pollution with greenhouse gases (CO2, CH4, NH3 and N2O) and dust (PM2.5 and PM10). They are recognized as the cause of global warming and air pollution. Wind, water, solar and biomass energy are used to eliminate harmful emissions. The latter may come from special plant crops or from biodegradable waste from farming, animal husbandry, the agrifood industry and households. These wastes are transformed into biogas in biogas plants, the basic ingredient of which is methane. Most often, biogas is burned in a cogeneration process, providing electricity and heat. After purification of admixtures, it can be injected into the high-methane gas network or converted into hydrogen in the steam reforming process. In this way, environmentally harmful waste becomes a raw material for energy production, which is an example of a circular economy. The article discusses the functioning of biogas plants in selected EU countries. The current biogas production in Poland was assessed and compared with the production potential of dairy farms. The aim of this article was to show that the production of biogas reduces the emission of greenhouse gases into the atmosphere and the electricity produced from it is not burdened with the cost of purchasing CO2 emission allowances applicable in the EU.