The law of reflection (that the angles of incidence and reflection are equal) can be derived directly from Maxwell's equations, or from Fermat's principle. However, reflection gratings completely defy this law, and from light incident at a fixed angle comes a whole diffraction pattern - light reflected at a range of different angles.
My teachers and textbooks tend to gloss over this point. Why do reflection gratings work, and why is there not a contradiction with the law of reflection?