Regulatory systems that maintain prophage quiescence integrate phage and host gene expression with environmental conditions1,2. In the opportunistic bacterial pathogen Pseudomonas aeruginosa, Pf filamentous bacteriophages play critical roles in biofilm formation and virulence3-5, but mechanisms governing Pf prophage activation in biofilms are largely unknown. Here, we report a new type of prophage regulatory module in a widely-distributed P. aeruginosa lineage that not only controls virion production of co-resident Pf prophages, but also mediates defense against diverse lytic phages. By comparing two lineages of the prototype P. aeruginosa strain PAO1 that harbor different Pf prophages, we identified a prophage-encoded kinase-kinase-phosphatase (KKP) system that controls Pf production in biofilms. KKP components exhibit dynamic stoichiometry, where high kinase levels in planktonic conditions maintain phosphorylation of the host H-NS protein MvaU, repressing prophage activation. During biofilm formation, phosphatase expression is heightened, leading to MvaU dephosphorylation and alleviating repression of prophage gene expression. KKP clusters are present in hundreds of diverse temperate prophages and other mobile elements across Gram-negative bacteria. Characterization of KKP modules from different species revealed that, in addition to regulating Pf phage lysogeny, KKP functions as a tripartite toxin-antitoxin system that mediates host defense from predatory lytic phages. KKP represents a new phosphorylation-based mechanism for prophage regulation and for phage defense. The dual function of this module raises the question of whether other newly described phage defense systems6-9 also regulate intrinsic prophage biology in diverse hosts.