In the vagina, lactic acid is primarily produced by Lactobacillus bacteria. These beneficial bacteria convert glycogen, a type of sugar found in vaginal cells, into lactic acid. This process helps to maintain an acidic pH, typically around 3.5 to 4.5, which is optimal for vaginal health. The acidic environment inhibits the growth of harmful bacteria and yeast, thereby providing a natural defense mechanism against infections.