Bacteria harbour at least 10 different types of secretion systems to export various virulence factors including small molecules, proteins and DNA across the bacterial cell envelope. These specialized nanomachines are attractive drug targets, however structural studies of these molecular machines are daunting because these are often multi-megadalton flexible complexes that span the entire length of the cell envelope and attempts to purify them disrupt their structure and composition. We harness the unique power of electron cryotomography and subtomogram averaging method to investigate these molecular machines in situ, in their native context, at macromolecular resolution. In my talk, I will discuss how we used electron cryotomography and subtomogram averaging to investigate the molecular architecture and biogenesis of the bacterial Type IV Secretion System (T4SS) utilized by the human pathogen Legionella pneumophila. Our detailed structural analysis mapped the location of the core and accessory components and revealed the molecular organization of the Legionella T4SS. An in-depth examination of the biogenesis pathway revealed that the T4SS complex assembles by an innovative “outside-inside” mechanism.