SAMHD1 is a dGTP-activated deoxynucleoside triphosphate triphosphohydrolase (dNTPase) whose dNTPase activity has been linked to HIV/SIV restriction. The mechanism of its dGTP-activated dNTPase function remains unclear. Recent data also indicate that SAMHD1 regulates retrotransposition of LINE-1 elements. Here we report the 1.8-angstrom crystal structure of homotetrameric SAMHD1 in complex with the allosteric activator and substrate dGTP/dATP. The structure indicates the mechanism of dGTP-dependent tetramer formation, which requires the cooperation of three subunits and two dGTP/dATP molecules at each allosteric site. Allosteric dGTP binding induces conformational changes at the active site, allowing a more stable interaction with the substrate and explaining the dGTP-induced SAMHD1 dNTPase activity. Mutations of dGTP binding residues in the allosteric site affect tetramer formation, dNTPase activity and HIV-1 restriction. dGTP-triggered tetramer formation is also important for SAMHD1-mediated LINE-1 regulation. The structural and functional information provided here should facilitate future investigation of SAMHD1 function, including dNTPase activity, LINE-1 modulation and HIV-1 restriction.