Sulfolipid-1 (SL-1) is an abundant sulfated glycolipid and potential virulence factor found in Mycobacterium tuberculosis. SL-1 consists of a trehalose-2-sulfate (T2S) disaccharide elaborated with four lipids. We identified and characterized a conserved mycobacterial sulfotransferase, Stf0, which generates the T2S moiety of SL-1. Biochemical studies demonstrated that the enzyme requires unmodified trehalose as substrate and is sensitive to small structural perturbations of the disaccharide. Disruption of stf0 in Mycobacterium smegmatis and M. tuberculosis resulted in the loss of T2S and SL-1 formation, respectively. The structure of Stf0 at a resolution of 2.6 A reveals the molecular basis of trehalose recognition and a unique dimer configuration that encloses the substrate into a bipartite active site. These data provide strong evidence that Stf0 carries out the first committed step in the biosynthesis of SL-1 and establish a system for probing the role of SL-1 in M. tuberculosis infection.