A method for controlling the activity of sulfate reducing bacteria or methanogenic archaea (or both) in environments containing such organisms comprising treating the environment with free nitrous acid (HNO2) or with a solution containing nitrite (NO2−) having a pH of less than 7 or by adding nitrite to the environment and having a pH of less than 7 in the environment. The method can also disrupt biofilms.