When the Id makes an instinctual demand of an erotic or aggressive nature on a uman being, the most simple and natural response for the ego, which governs the apparatus for thinking and muscle inervation, is to satisfy this by an action. This satisfaction of the instinct is felt as pleasure by the Ego, just as not satisfying lis instinct would undoubtedly become a source of discomfort.
Now, it may happen that the Ego eschews satisfaction of the instinct because of external obstacles-namely, when it realizes that the action in question would bring in its course serious danger to the Ego. Such a refraining from satisfaction, an "instinctual renunciation" because of external obstacles-as we say, in obedience to the reality-principle-is never pleasurable. The instinctual renunciation would bring about a lasting painful tension if we did not succeed in diminishing the strength of the instinctual urge itself through a displacement of energy. This instinctual renunciation may also be forced on us, however, by other motives, which we rightly call inner ones. In the course of individual development a part of the inhibiting forces in the outer world becomes internalized; a standard is created in the Ego which opposes the other faculties by observation, criticism, and prohibition. We call this new standard the Super-ego .... While, however, instinctual renunciation for external reasons is only painful, renunciation for internal reasons, in obedience to the demands of the Super-ego, has another economic effect. It brings besides the inevitable pain a gain in pleasure to the Ego-as it were, a substitutive satisfaction.
- Template:M&M Part III, Section II