Double-stranded DNA (dsDNA) viruses such as herpesviruses and bacteriophages infect by delivering their genetic material into cells, a task mediated by a DNA channel called "portal protein." We have used electron cryomicroscopy to determine the structure of bacteriophage P22 portal protein in both the procapsid and mature capsid conformations. We find that, just as the viral capsid undergoes major conformational changes during virus maturation, the portal protein switches conformation from a procapsid to a mature phage state upon binding of gp4, the factor that initiates tail assembly. This dramatic conformational change traverses the entire length of the DNA channel, from the outside of the virus to the inner shell, and erects a large dome domain directly above the DNA channel that binds dsDNA inside the capsid. We hypothesize that this conformational change primes dsDNA for injection and directly couples completion of virus morphogenesis to a new cycle of infection.