Diffraction is a phenomena that all waves undergo. It is by definition the capacity of waves to go around an obstacle that has linear dimensions less than or comparable with the wavelength. Diffraction is is due to the Huygens principle which says that each point that has been reached by the wave front becomes to radiate itself waves. Thus when an wave reaches an obstacle the ending points of the obstacle behave like a wave generator (provided the wavelength is smaller than the obstacle). Because of this, the points situated in space after the obstacle will undergo the same oscillations as the points in space before the obstacle and the wave will "go around" the obstacle.

Because there are now not only one but multiple sources of waves, in any point of space after the obstacle the amplitude of the oscillation will be the sum of all incoming oscillations. Each wave that arrives in a point will have a certain phase that depends on the length of the path it traveled from the radiating source to that point. The resulting oscillating amplitude will depend on the difference of path between these incoming waves.

For a narrow slit, it is considered that diffraction occurs because of the difference in path of the wave emitted by one end of the slit (point A in the figure below) and one point in the middle of the slit (point B in the figure below). For a grating it is considered that diffraction occurs between waves emitted by two consecutive openings in the grating (points C and D in the figure below).

In both cases the condition of maxima of oscillation at point E on the screen is the same

`d*sin(theta) =k*lambda` , where `k` is an integer.