Steroidal alkaloids (SAs) and steroidal glycoalkaloids (SGAs) are common constituents of plant species belonging to the Solanaceae family. However, the molecular mechanism regulating the formation of SAs and SGAs remains unknown. Here, genome-wide association mapping was used to elucidate SA and SGA regulation in tomatoes: a SlGAME5-like glycosyltransferase (Solyc10g085240) and the transcription factor SlDOG1 (Solyc10g085210) were significantly associated with steroidal alkaloid composition. In this study, it was found that rSlGAME5-like can catalyze a variety of substrates for glycosidation and can catalyze SA and flavonol pathways to form O-glucoside and O-galactoside in vitro. The overexpression of SlGAME5-like promoted α-tomatine, hydroxytomatine, and flavonol glycoside accumulation in tomatoes. Furthermore, assessments of natural variation combined with functional analyses identified SlDOG1 as a major determinant of tomato SGA content, which also promoted SA and SGA accumulation via the regulation of GAME gene expression. This study provides new insights into the regulatory mechanisms underlying SGA production in tomatoes.