One of the three major substructures of the bacterial-type flagellum, the basal body is embedded in the cell envelope (the plasma membrane, peptidoglycan cell wall, and, if one is present, the outer membrane); it houses the secretion apparatus that exports the more distal components and the flagellar motor.