Methanogens belong to a group of ancient microbes known as archaea. They have evolved hundreds of millions of years ago and occupy oxygen-free niches such as peat bogs and anaerobic gut systems.
In the rumen, methanogens modify the fermentation process, but they are not thought to be essential to the host animal. They are opportunists, taking advantage of one of the by-products of fermentation in the rumen: hydrogen gas. This provides an energy sourceand methanogens combine it with carbon dioxide to produce methane and water. The methane is released into the atmosphere when the animal belches. The methanogens’ use of hydrogen represents a loss of dietary energy to the animal. The small blue cells in the image below methanogen cells in the gut contents of a sheep. 

Read more about enteric fermentation
Read more about NZ methane mitigation research