Diabetes is far more prevalent in smokers than non-smokers, but the underlying mechanisms of vulnerability are unknown. Here we show that the diabetes-associated gene Tcf7l2 is densely expressed in the medial habenula (mHb) region of the rodent brain, where it regulates the function of nicotinic acetylcholine receptors. Inhibition of TCF7L2 signalling in the mHb increases nicotine intake in mice and rats. Nicotine increases levels of blood glucose by TCF7L2-dependent stimulation of the mHb. Virus-tracing experiments identify a polysynaptic connection from the mHb to the pancreas, and wild-type rats with a history of nicotine consumption show increased circulating levels of glucagon and insulin, and diabetes-like dysregulation of blood glucose homeostasis. By contrast, mutant Tcf7l2 rats are resistant to these actions of nicotine. Our findings suggest that TCF7L2 regulates the stimulatory actions of nicotine on a habenula-pancreas axis that links the addictive properties of nicotine to its diabetes-promoting actions.