Take leaf-cutter ants as an example. I'm sure that most readers of this blog will know they cut sections of vegetation, take them into their nest, and grow fungus on them. The fungus is what the ants eat, they have evolved to become farmers. The evolutionary history of this relationship is interesting, but there are other players.
In 1999 it was found that the fungus gardens are helped by antibiotic producing bacterium that controls parasites. It has recently been found that an additional species of bacteria is used to fix atmospheric nitrogen, making it available to the fungus. As well as crop protection bacteria also provide the fungus gardens with fertiliser.
You can read more over at Myrmecos: Ant fungus gardens fix atmospheric nitrogen.