Bacteria have evolved a broad range of systems that provide defence against their viral predators, bacteriophages. Bacteriophage Exclusion (BREX) systems recognise and methylate 6 bp non-palindromic motifs within the host genome, and prevent replication of non-methylated phage DNA that encodes these same motifs. How BREX recognises cognate motifs has not been fully understood. In this study we characterise BREX from pathogenic Salmonella and present X-ray crystallographic structures of the conserved BREX protein, PglX. The PglX N-terminal domain encodes the methyltransferase, whereas the C-terminal domain is for motif recognition. We also present the structure of PglX bound to the phage-derived DNA mimic, Ocr, an inhibitor of BREX activity. Our analyses propose modes for DNA-binding by PglX and indicate that both methyltransferase activity and defence require larger BREX complexes. Through rational engineering of PglX we broaden both the range of phages targeted, and the host motif sequences that are methylated by BREX. Our data demonstrate that PglX is used to recognise specific DNA sequences for BREX activity, contributing to motif recognition for both phage defence and host methylation.