In this paper, we solve, for the first time, electromagnetic wave propagation equations in heterogeneous media using the spectral moments method. This numerical method, first developed in condensed matter physics, was recently successfully applied to acoustic waves propagation simulation in geophysics. The method requires the introduction of an auxiliary density function, which can be calculated by the moments technique. This allows computation of the Green's function of the whole system as a continued fraction in time Fourier domain. The coefficients of the continued fraction are computed directly from the dynamics matrix obtained by discretization of wave propagation equations and from the sources and receivers. We illustrate this method through the study of a plane wave diffraction by a slit in two-dimensional (2-D) media and by a rectangular aperture in three-dimensional (3-D) media. Comparison with analytical results obtained with the Kirchhoff theory shows that this method is a very powerful tool to solve propagation equations in heterogeneous media. Last, we present a brief comparison with other computing methods.