Carrying capacity in ecology refers to the maximum population size of a species that a specific environment or habitat can sustain indefinitely. It is determined by factors such as the availability of resources like food, water, and shelter, as well as competition, predation, and disease. When a population exceeds the carrying capacity of its environment, it can lead to resource depletion, environmental degradation, and ultimately a decline in population size as the ecosystem struggles to support the excess individuals.