A microbial fuel cell includes an anode compartment with an anode and an anode biocatalyst and a cathode compartment with a cathode and a cathode biocatalyst, with a membrane positioned between the anode compartment and the cathode compartment, and an electrical pathway between the anode and the cathode. The anode biocatalyst is capable of catalyzing oxidation of an organic substance, and the cathode biocatalyst is capable of catalyzing reduction of an inorganic substance. The reduced organic substance can form a precipitate, thereby removing the inorganic substance from solution. In some cases, the anode biocatalyst is capable of catalyzing oxidation of an inorganic substance, and the cathode biocatalyst is capable of catalyzing reduction of an organic or inorganic substance.