Ferment has the following meanings:
1. To undergo or to cause the gradual decomposition of an organic compound induced by enzymes, bacteria, yeast, etc.: “They want to ferment hops and barley so they can make some beer at home.”
2. A situation in which there is much excitement and confusion caused by some kind of change: “After the opposing political party finally won the election, the town was in a state of ferment.”
Foment, on the other hand, means to cause or to try to cause the growth or development of something bad or harmful: “To foment or to incite people to plan a revolution without thinking can have very serious consequences!”