Motors generating mechanical force, powered by the hydrolysis of ATP, translocate double-stranded DNA into preformed capsids (proheads) of bacterial viruses and certain animal viruses. Here we describe the motor that packages the double-stranded DNA of the Bacillus subtilis bacteriophage phi29 into a precursor capsid. We determined the structure of the head-tail connector--the central component of the phi29 DNA packaging motor--to 3.2 A resolution by means of X-ray crystallography. We then fitted the connector into the electron densities of the prohead and of the partially packaged prohead as determined using cryo-electron microscopy and image reconstruction analysis. Our results suggest that the prohead plus dodecameric connector, prohead RNA, viral ATPase and DNA comprise a rotary motor with the head-prohead RNA-ATPase complex acting as a stator, the DNA acting as a spindle, and the connector as a ball-race. The helical nature of the DNA converts the rotary action of the connector into translation of the DNA.