Disclosed herein is a method of producing a polyaniline zirconia nanocomposite, and the uses of the thus produced polyaniline zirconia nanocomposite for the treatment of wastewater. The polyaniline zirconia nanocomposite is characterized in having a particle size of about 0.3 to 50 μm in diameter, an isoelectric point at about pH 6.2, and is capable of reducing at least 99% of the pathological microorganism and at least 60% of the phosphate in the wastewater after coming into contact with wastewater for 24 hrs and 12 hrs, respectively.