Bacteria have evolved ‘immune systems’ as a result of their constant exposure to foreign mobile genetic elements, including bacteriophages and plasmids. For example, an estimated 1025 bacteriophage infections occur every second, which affect global nutrient cycles. Other mobile genetic elements can harbour antibiotic resistance or pathogenicity determinants, which influence bacterial evolution and our ability to treat infectious disease. To thwart these invaders, bacteria have many resistance strategies, including innate immunity, such as restriction-modification and abortive infection systems, and adaptive immunity provided by the CRISPR-Cas systems. Recently, there have been major advances in our understanding of these systems. They have also been exploited as molecular biology reagents and led to a new biotechnology revolution. I will present our recent research into the function of these fascinating adaptive immune systems in bacteria.