The question of why people are motivated to act altruistically has been an important one for centuries, and across various disciplines. Drawing on previous research on moral regulation, we propose a framework suggesting that moral (or immoral) behavior can result from an internal balancing of moral self-worth and the cost inherent in altruistic behavior. In Experiment 1, participants were asked to write a self-relevant story containing words referring to either positive or negative traits. Participants who wrote a story referring to the positive traits donated one fifth as much as those who wrote a story referring to the negative traits. In Experiment 2, we showed that this effect was due specifically to a change in the self-concept. In Experiment 3, we replicated these findings and extended them to cooperative behavior in environmental decision making. We suggest that affirming a moral identity leads people to feel licensed to act immorally. However, when moral identity is threatened, moral behavior is a means to regain some lost self-worth.