This paper introduces a fast algorithm, applicable throughout the electromagnetic spectrum, for the numerical solution of problems of scattering by two-dimensional periodic surfaces. In particular, the proposed algorithm remains highly accurate and efficient for challenging configurations including randomly rough surfaces, deep corrugations, large periods, near grazing incidences, and,
... [Show full abstract] importantly, Wood-anomaly resonant frequencies. The proposed approach is based on use of certain "shifted equivalent sources" which enable FFT acceleration of a Wood-anomaly-capable quasi-periodic Green function introduced recently (Bruno and Delourme, Jour. Computat. Phys., 262--290, 2014). The Green-function strategy is supplemented, further, by the incorporation an exponentially convergent shifted version of the classical spectral series for the Green function. Single-core runs in computing times ranging from a fraction of a second to a few seconds suffice for the proposed algorithm to produce highly-accurate solutions in some of the most challenging contexts arising in applications. The algorithm is additionally demonstrated for certain extreme geometries featuring hundreds of wavelengths in period and/or depth, for which accurate solutions are obtained in single-core runs of the order of a few minutes.