TECHNOLOGY FOCUS - ORGANIC CHEMISTRY - Preferred Method: The first fermentation stage is carried out via batch wise and the further stages of fermentation are carried out in a continuous manner. At least sulfur compounds and ammonia are partially removed from the biogas obtained in the first fermentation stage. The carbon-dioxide content is measured in the biogas obtained in the first fermentation stage, and completing the first fermentation stage, when carbon-dioxide content reaches at least 60%. The methane content is measured in the biogas obtained in the first fermentation stage, and completing the first fermentation stage, when methane content reaches 10-40 vol.%, preferably 15-20 vol.%, in the non-combustible range. The hydrogen content is measured in the biogas obtained in the first fermentation stage, and completing the first fermentation stage after reaching a peak concentration of hydrogen with less than 0.5 vol.%, preferably 0.2 vol.%, in non-combustible range of the biogas. The hydrogen sulfide content is measured in the biogas obtained in the first fermentation stage, and completing the first fermentation stage after reaching a peak concentration of hydrogen sulfide with less than 0.2 vol.%, preferably 0.05 vol.%,, in non-combustible range of the biogas. The biomass is adjusted to a dry substance content of 2-15%, during the first fermentation stage. The dry matter content of the fermentation substrate obtains maximum value in the second stage of the fermentation. The second fermentation stage is operated with a loading rate of 0.5-10 kg oDM/m3d, preferably 1-6 kg oDM/m3d. The fermentation substrate is treated in the second and subsequent stages of fermentation at temperatures that are lower than the temperature in the first fermentation stage, but not a temperature of below 25 degrees C. The fermentation liquid from the second and/or subsequent fermentation stages in previous stages of fermentation is recycled for adjusting the dry substance content of the fermentation substrate. The fermentation substrate based on another raw material with a starch content of less than 10%, is added in the second and/or the subsequent stages of fermentation. EXAMPLE - Corn silage (2000 kg/day) as raw material, was utilized to carry out the first fermentation stage, the first fermenter (volume of 25 m3) was supplied with acidophilic fermentation liquid (20 m3) from the first container. The fermentation liquid was heated at a temperature of 55 degrees C, and was maintained by means of integrated heating at a temperature of 50 degrees C, for 24 hours, and the pH of the fermentation substrate was adjusted to 6.9-5.36, to obtain the biogas (104 Nm3) within 22 hours with 77.9 vol.% of carbon-dioxide 21.6 vol.% of methane, 0.34 vol.% of hydrogen, 0.21 vol.% hydrogen sulfide, and 0.07 vol.% of ammonia, which was removed through the line and purified by a conventional gas, and washing and drying, where hydrogen sulfide, ammonia and carbon-dioxide were removed. The biogas removed via line comprised 22.46 m3 of methane. The amount of methane in the biogas removed from the line, was measured, and the first fermentation stage was terminated on reaching a measured value of 30 vol.%. The fermentation substrate was supplied via the line, by means of the pump, from the first fermenter, through the separation unit, to the second fermenter, to carry out second fermentation stage, and the fermentation substrate was maintained at a constant temperature of 40 degrees C, to obtain the biogas (309 Nm3/day) with 210 Nm3 of methane and 99 Nm3 of carbon-dioxide.