A method capable of protecting an ecosystem and effectively protecting the nature by effectively treating wastewater containing high concentration organic matters, nitrogen, phosphorous and the like such as livestock wastewater, leachate and excretions is provided. A method for treating wastewater such as livestock wastewater, leachate and excretions comprises: reacting wastewater supplied into a reaction tank(2) with a catalyst in which magnesium is mixed with calcium, thereby producing MgNH4PO4À6H2O and Ca10(OH)2(PO4)6 to primarily treat wastewater by removing ammonia nitrogen, phosphorous, solids and nitrogen; removing organic matters from the primarily treated water in an organic acid tank(3) and a methane fermentation tank(4) in which methane-producing bacteria are filled to secondly treat the treated water; injecting the secondly treated water into a nitrification tank(5) charged with nitrifying bacteria to thirdly treat the secondly treated water by converting ammonia nitrogen into nitrate nitrogen or