Potato (Solanum tuberosum), a worldwide major food crop, produces the toxic, bitter tasting solanidane glycoalkaloids α-solanine and α-chaconine. Controlling levels of glycoalkaloids is an important focus on potato breeding. Tomato (Solanum lycopersicum) contains a bitter spirosolane glycoalkaloid, α-tomatine. These glycoalkaloids are biosynthesized from cholesterol via a partly common pathway, although the mechanisms giving rise to the structural differences between solanidane and spirosolane remained elusive. Here we identify a 2-oxoglutarate dependent dioxygenase, designated as DPS (Dioxygenase for Potato Solanidane synthesis), that is a key enzyme for solanidane glycoalkaloid biosynthesis in potato. DPS catalyzes the ring-rearrangement from spirosolane to solanidane via C-16 hydroxylation. Evolutionary divergence of spirosolane-metabolizing dioxygenases contributes to the emergence of toxic solanidane glycoalkaloids in potato and the chemical diversity in Solanaceae.