We report crystal structures of the citrate and sn-glycerol-1-phosphate (G1P) complexes of (S)-3-O-geranylgeranylglyceryl phosphate synthase from Archaeoglobus fulgidus (AfGGGPS) at 1.55 and 2.0 A resolution, respectively. AfGGGPS is an enzyme that performs the committed step in archaeal lipid biosynthesis, and it presents the first triose phosphate isomerase (TIM)-barrel structure with a prenyltransferase function. Our studies provide insight into the catalytic mechanism of AfGGGPS and demonstrate how it selects for the sn-G1P isomer. The replacement of "Helix 3" by a "strand" in AfGGGPS, a novel modification to the canonical TIM-barrel fold, suggests a model of enzyme adaptation that involves a "greasy slide" and a "swinging door." We propose functions for the homologous PcrB proteins, which are conserved in a subset of pathogenic bacteria, as either prenyltransferases or being involved in lipoteichoic acid biosynthesis. Sequence and structural comparisons lead us to postulate an early evolutionary history for AfGGGPS, which may highlight its role in the emergence of Archaea.