Bacteria use diverse mechanisms to protect themselves against phages1–6. Many antiphage systems form large oligomeric complexes, but how oligomerization is regulated during phage infection remains mostly unknown7–12. Here we demonstrate that the bacterial immunity protein ring-activated zinc-finger RNase (RAZR) assembles into an active, 24-meric ring around the circumference of large ring structures formed by two unrelated phage proteins: a putative recombinase and a portal protein. Each multi-layered, megadalton-scale complex enables RAZR to cleave RNA nonspecifically to inhibit translation and restrict phage propagation. The recognition of unrelated phage proteins that form rings with similar diameters indicates that these proteins not only bind to RAZR but also enforce a geometry crucial to activation. The lack of large ring structures in the host probably prevents auto-immunity and RAZR activation before infection. The infection-triggered oligomerization of RAZR mirrors pathogen-induced oligomerization in eukaryotic innate immune complexes13, underscoring a common principle of immunity across biology.