Nicotinamide mononucleotide adenylyltransferase (NMNAT) is a conserved enzyme in the NAD synthetic pathway. It has also been identified as an effective and versatile neuroprotective factor. However, it remains unclear how healthy neurons regulate the dual functions of NMNAT and achieve self-protection under stress. Here we show that Drosophila Nmnat (DmNmnat) is alternatively spliced into two mRNA variants, RA and RB, which translate to protein isoforms with divergent neuroprotective capacities against spinocerebellar ataxia 1-induced neurodegeneration. Isoform PA/PC translated from RA is nuclear-localized with minimal neuroprotective ability, and isoform PB/PD translated from RB is cytoplasmic and has robust neuroprotective capacity. Under stress, RB is preferably spliced in neurons to produce the neuroprotective PB/PD isoforms. Our results indicate that alternative splicing functions as a switch that regulates the expression of functionally distinct DmNmnat variants. Neurons respond to stress by driving the splicing switch to produce the neuroprotective variant and therefore achieve self-protection.