A method for purification of carbon-containing wastewater, comprising: a) providing wastewater having a BOD of at least 300 mg/L; b) reducing O 2 content of said wastewater by unaerated aerobic digestion such that the O 2 content of wastewater after said unaerated aerobic digestion is not more than 2 mg/L, so that the population of microorganisms in said wastewater changes from more aerobic microorganisms to fewer aerobic microorganisms; and transferring said wastewater with reduced O 2 content from said unaerated aerobic digestion to anaerobic digestion; c) subsequently to 'b', eliminating substantially all O 2 from said wastewater by anaerobic digestion, the conditions of said anaerobic digestion such that the population of aerobic microorganisms in said wastewater is no longer viable; d) subsequently to 'c', transferring said wastewater to a photobioreactor, said photobioreactor closed to prevent microorganisms from the surroundings from entering said photobioreactor; e) subsequently to 'd', maintaining said wastewater in said closed photobioreactor in conditions favorable for algal photosynthesis, thereby allowing algae to grow in said photobioreactor, wherein the conditions in said photobioreactor are such that the algal population is predominantly planktonic algae; wherein said wastewater is circulated in said photobioreactor to provide purified wastewater; and f) removing said purified wastewater from said photobioreactor, wherein said purified wastewater removed from said bioreactor has a BOD of between 2 and 5 mg/L, wherein conditions of said transferring 'd' and/or said maintaining 'e' are such that subsequent to said maintaining 'e', the population of microorganisms from said anaerobic digestion in said wastewater is no longer viable, and wherein said algae grow in said photobioreactor without competition from other microorganisms. a) providing wastewater having a BOD of at least 300 mg/L; b) reducing O 2 content of said wastewater by unaerated aerobic digestion such that the O 2 content of wastewater after said unaerated aerobic digestion is not more than 2 mg/L, so that the population of microorganisms in said wastewater changes from more aerobic microorganisms to fewer aerobic microorganisms; and transferring said wastewater with reduced O 2 content from said unaerated aerobic digestion to anaerobic digestion; c) subsequently to 'b', eliminating substantially all O 2 from said wastewater by anaerobic digestion, the conditions of said anaerobic digestion such that the population of aerobic microorganisms in said wastewater is no longer viable; d) subsequently to 'c', transferring said wastewater to a photobioreactor, said photobioreactor closed to prevent microorganisms from the surroundings from entering said photobioreactor; e) subsequently to 'd', maintaining said wastewater in said closed photobioreactor in conditions favorable for algal photosynthesis, thereby allowing algae to grow in said photobioreactor, wherein the conditions in said photobioreactor are such that the algal population is predominantly planktonic algae; wherein said wastewater is circulated in said photobioreactor to provide purified wastewater; and f) removing said purified wastewater from said photobioreactor,