Bacteria contain a wide variety of innate and adaptive immune systems which provide protection to the host against invading genetic material, including bacteriophages (phages). It is becoming increasingly clear that bacterial immune systems are frequently lost and gained through horizontal gene transfer (HGT). However, how and when new immune systems can become established in a bacterial population has remained largely unstudied. We developed a joint epidemiological and evolutionary model that predicts the conditions necessary for the spread of a CRISPR-Cas immune system into a bacterial population lacking this system. We find that whether bacteria carrying CRISPR-Cas will spread (increase in frequency) into a bacterial population depends on the abundance of phages and the difference in the frequency of phage resistance mechanisms between bacteria carrying a CRISPR-Cas immune system, and those not (denoted as ${f}_{\Delta }$). Specifically, the abundance of cells carrying CRISPR-Cas will increase if there is a higher proportion of phage resistance (either via CRISPR-Cas immunity or surface modification) in the CRISPR-Cas possessing population than in the cells lacking CRISPR-Cas. We experimentally validated these predictions using Pseudomonas aeruginosa PA14 and phage DMS3vir as a model. Specifically, by varying the initial ratios of different strains of bacteria that carry alternative forms of phage resistance we confirmed that the spread of cells carrying CRISPR-Cas through a population can be predicted based on phage density and the relative frequency of resistance phenotypes. Understanding which conditions promote the spread of CRISPR-Cas systems helps to predict when and where these defences can establish in bacterial populations after a horizontal gene transfer event, both in ecological and clinical contexts.