The present invention relates to methods for producing ethanol and methane from biomass. The clear phase of a pulp obtained by fermentation of milled biomass is used for obtaining methane gas for energy production and for conversion in a combined heat and power production of energy and steam. The anaerobically purified clear phase of the pulp can additionally be purified aerobically to enable reuse of the water in the process. The solid phase of the pulp can be utilized for obtaining a high quality feeding stuff or burned for production of energy.