When you use the DFT/FFT to find the frequency content of a signal, it is inherently assumed that the data that you have is a single period of a periodically repeating waveform, as shown in the following illustration. The first period shown is the one sampled. The waveform corresponding to this period is then repeated in time to produce the periodic waveform.
As seen in the previous illustration, because of the assumption of periodicity of the waveform, discontinuities between successive periods will occur. This happens when you sample a noninteger number of cycles. These artificial discontinuities turn up as high frequencies in the spectrum of the signal, frequencies that were not present in the original signal. These frequencies could be much higher than the Nyquist frequency, and as you have seen before, will be aliased somewhere between 0 and fs/2. The spectrum you get by using the DFT/FFT therefore will not be the actual spectrum of the original signal, but will be a smeared version. It appears as if the energy at one frequency has leaked out into all the other frequencies. This phenomenon is known as spectral leakage.
The following illustration shows a sine wave and its corresponding Fourier transform. The sampled time domain waveform is shown in Graph 1. Because the Fourier transform assumes periodicity, you repeat this waveform in time, and the periodic time waveform of the sine wave of Graph 1 is shown in Graph 2. The corresponding spectral representation is shown in Graph 3. Because the time record in Graph 2 is periodic, with no discontinuities, its spectrum is a single line showing the frequency of the sine wave. The reason that the waveform in Graph 2 does not have any discontinuities is because you have sampled an integer number of cycles (in this case, 1) of the time waveform.
In the following illustration, you see the spectral representation when you sample a noninteger number of cycles of the time waveform (namely 1.25). Graph 1 now consists of 1.25 cycles of the sine wave. When you repeat this periodically, the resulting waveform, as shown in Graph 2, consists of discontinuities. The corresponding spectrum is shown in Graph 3. Notice how the energy is now spread over a wide range of frequencies. This smearing of the energy is spectral leakage. The energy has leaked out of one of the FFT lines and smeared itself into all the other lines.
Leakage exists because of the finite time record of the input signal. To overcome leakage, one solution is to take an infinite time record, from infinity to +infinity. Then the FFT would calculate one single line at the correct frequency. Waiting for infinite time is, however, not possible in practice. So, because you are limited to having a finite time record, another technique, known as windowing, is used to reduce the spectral leakage.
The amount of spectral leakage depends on the amplitude of the discontinuity. The larger the discontinuity, the more the leakage, and vice versa. You can use windowing to reduce the amplitude of the discontinuities at the boundaries of each period. It consists of multiplying the time record by a finite length window whose amplitude varies smoothly and gradually towards zero at the edges. This is shown in the previous illustration, where the original time signal is windowed using a Hanning window. Notice that the time waveform of the windowed signal gradually tapers to zero at the ends. Therefore, when performing Fourier or spectral analysis on finite-length data, you can use windows to minimize the transition edges of your sampled waveform. A smoothing window function applied to the data before it is transformed into the frequency domain minimizes spectral leakage.
Note that if the time record contains an integral number of cycles, then the assumption of periodicity does not result in any discontinuities, and thus there is no spectral leakage. The problem arises only when you have a nonintegral number of cycles.