A method of moments solution is presented for the problem of twodimensional transverse magnetic (TM) scattering of a plane wave from a nonplanar periodic surface separating two contrasting homogeneous media. The moment solution uses fictitious spatially periodic and properly modulated electric current strips to simulate the field scattered by the surface and the field penetrated through the surface. The fields radiated by the current strips are represented in terms of Floquet modes and the problem is reduced to a consideration of the fields over a single period. Finally, the simulated fields are forced to obey the continuity conditions for the tangential components of the electric and magnetic fields at a selected set of points on the interface within a single period. The procedure is simple to implement, rapidly converging, and is applicable to arbitrary smooth profiles. Perfectly conducting media are treated as reduced cases of the general procedure for penetrable media. Results for sinusoidal surfaces are given and compared with available data. The efficiency of the suggested method is demonstrated.