The phenomenon is primarily due to Rayleigh scattering, which is the scattering of light by particles much smaller than the wavelength of light (like gas molecules in the atmosphere). Rayleigh scattering is more effective at scattering shorter wavelengths (blue, violet) than longer wavelengths (red, orange). At sunset and sunrise, sunlight travels through a much larger thickness of the atmosphere. During this long passage, most of the shorter wavelengths are scattered away by atmospheric particles, leaving the longer wavelengths (red and orange) to reach the observer's eyes directly from the Sun.