Herd immunity, also known as community immunity, occurs when a significant portion of a population becomes immune to a disease, thereby reducing the likelihood of disease spread. This can be achieved through vaccination or previous infection. When enough people are immune, it provides indirect protection to those who are not immune, such as individuals with compromised immune systems.