Many icosahedral viruses use a specialized portal vertex to control genome encapsidation and release from the viral capsid. In tailed bacteriophages, the portal system is connected to a tail structure that provides the pipeline for genome delivery to the host cell. We report the first, to our knowledge, subnanometer structures of the complete portal-phage tail interface that mimic the states before and after DNA release during phage infection. They uncover structural rearrangements associated with intimate protein-DNA interactions. The portal protein gp6 of bacteriophage SPP1 undergoes a concerted reorganization of the structural elements of its central channel during interaction with DNA. A network of protein-protein interactions primes consecutive binding of proteins gp15 and gp16 to extend and close the channel. This critical step that prevents genome leakage from the capsid is achieved by a previously unidentified allosteric mechanism: gp16 binding to two different regions of gp15 drives correct positioning and folding of an inner gp16 loop to interact with equivalent loops of the other gp16 subunits. Together, these loops build a plug that closes the channel. Gp16 then fastens the tail to yield the infectious virion. The gatekeeper system opens for viral genome exit at the beginning of infection but recloses afterward, suggesting a molecular diaphragm-like mechanism to control DNA efflux. The mechanisms described here, controlling the essential steps of phage genome movements during virus assembly and infection, are likely to be conserved among long-tailed phages, the largest group of viruses in the Biosphere.DNA gatekeeper | viral infection | bacteriophage | allosteric mechanism | hybrid methods