Refraction, accompanied with reflection is involved in all photonic devices, including emerging photonic materials constructed with lossy materials. However, refraction in a lossy medium is still a puzzle up to this day even though the law of refraction for lossless media, Snell’s law, was discovered over a millennium ago. To obtain predictable designs and allow for valuable evaluation of photonic materials, a general law of refraction valid for lossy media becomes indispensable. Here we derive it from the phase continuity of electromagnetic waves by introducing a transition layer of permittivity and permeability with gradual variations between two media, instead of the single physical interface. It well simulates our experimental results of reflectance vs. incident angle and polarization at the interface of glass and indium tin oxide coating at multi wavelengths, which cannot be done by complex Snell’s law. With a real refraction angle in lossy media, it finally solves the millennium puzzle of refraction in a lossy medium. It covers Snell’s law and reveals a new phenomenon of incident angle and polarization independent reflection, some kind of invisibility. It will contribute to the designs of photonic materials, correct the complex permittivity measured by ellipsometry and improve the design of external total reflection of X-ray.