All imaging gradients temporarily change the resonant frequencies of protons while the gradient is being applied. When the gradient is turned off, the protons go back to their original precession frequencies. However, these protons will have gained or lost phase relative to a reference state though they are now again resonating at the same frequency. They possess "memory" of their historical encounter with the gradient manifest by a permanent phase shift (Φ).
Advanced Discussion (show/hide)»
Although I frequently draw gradients as idealized rectangles, it is impossible to have an instantaneous change of gradient strength from zero to some arbitrary value. In real life, gradients are most frequently trapezoidal in shape with rise and fall times as described in prior Q&A's. Sometimes gradients have curvilinear shapes such as half or full sinusoids. Regardless of their exact shape the general principle still holds -- the area under a gradient is proportional to accumulated phase.
Brewer RG, Hahn EL. Atomic memory. Sci Amer 1984:251(6):50-57.
How does frequency-encoding work?