We consider electromagnetic waves in a medium described by a position dependent dielectric constant . We assume that is a random perturbation of a periodic function and that the periodic Maxwell operator has a gap in the spectrum, where . We prove the existence of localized waves, i.e., finite energy solutions of Maxwell's equations with the property that almost all of the wave's energy remains in a fixed bounded region of space at all times. Localization of electromagnetic waves is a consequence of Anderson localization for the self-adjoint operators . We prove that, in the random medium described by , the random operator exhibits Anderson localization inside the gap in the spectrum of . This is shown even in situations when the gap is totally filled by the spectrum of the random operator; we can prescribe random environments that ensure localization in almost the whole gap.