||Transcranial magnetic stimulation (TMS) is a widely applied tool for probing cognitive function in humans and is one of the best tools for clinical treatments and interfering with cognitive tasks. Surprisingly, while TMS has been commercially available for decades, the cellular mechanisms underlying magnetic stimulation remain unclear. Here we investigate these mechanisms using compartmental modeling. We generated a numerical scheme allowing simulation of the physiological response to magnetic stimulation of neurons with arbitrary morphologies and active properties. Computational experiments using this scheme suggested that TMS affects neurons in the central nervous system (CNS) primarily by somatic stimulation.