The "mechanism" is just the process of evolution itself, and how it plays out in practice, e.g. via punctuated equilibrium.
Over shorter timespans the gene pool of a breeding population incrementally drifts according to the success of individual genetics, but then once in a while, over multiple generations, something in the environment (disease, food, competition, etc) may change quickly and the gene pool as a whole, not just that of individuals, is thereby tested, with accumulations of previously benign changes sometimes suddenly becoming critical. In this way evolution is acting on the entire gene pool - of the species or more correctly of that interbreeding sub-population.
Success in evolution, the ability of the species as a whole to adapt and compete, also requires genetic diversity, not only to avoid inbreeding, but also to provide species level resilience, and species level ability to quickly adapt. e.g. It seems that the success of sexual reproduction is because it is a way to "game the game" by increasing genetic diversity and therefore improve along these axis of resilience and fast adaptation.
There are also social species, such as ourselves, where the social group becomes port of the individuals environment, and genetics best-fitted-to-the-environment becomes a group dynamic.