All viruses require strategies to inhibit or evade the immune pathways of cells that they infect. The viruses that infect bacteria, bacteriophages (phages), must avoid immune pathways that target nucleic acids, such as CRISPR-Cas and restriction-modification systems, to replicate efficiently1. Here we show that jumbo phage ΦKZ segregates its DNA from immunity nucleases of its host, Pseudomonas aeruginosa, by constructing a proteinaceous nucleus-like compartment. ΦKZ is resistant to many immunity mechanisms that target DNA in vivo, including two subtypes of CRISPR-Cas3, Cas9, Cas12a and the restriction enzymes HsdRMS and EcoRI. Cas proteins and restriction enzymes are unable to access the phage DNA throughout the infection, but engineering the relocalization of EcoRI inside the compartment enables targeting of the phage and protection of host cells. Moreover, ΦKZ is sensitive to Cas13a-a CRISPR-Cas enzyme that targets RNA-probably owing to phage mRNA localizing to the cytoplasm. Collectively, we propose that Pseudomonas jumbo phages evade a broad spectrum of DNA-targeting nucleases through the assembly of a protein barrier around their genome.