From intracellular protein trafficking to large-scale motion of animal groups, the physical concepts driving the self-organization of living systems are still largely unraveled. Self-organization of active entities, leading to novel phases and emergent macroscopic properties, recently shed new light on these complex dynamical processes. Here we show that under the application of a constant magnetic field, motile magnetotactic bacteria confined in water-in-oil droplets self-assemble into a rotary motor exerting a torque on the external oil phase. A collective motion in the form of a large-scale vortex, reversable by inverting the field direction, builds up in the droplet with a vorticity perpendicular to the magnetic field. We study this collective organization at different concentrations, magnetic fields and droplet radii and reveal the formation of two torque-generating areas close to the droplet interface. We characterize quantitatively the mechanical energy extractable from this new biological and self-assembled motor.