The process by which natural selection drives competing species into different patterns of resource use or different niches. Coexistence is obtained through the differentiation of their realized ecological niches.