Runaway stars produce shocks when passing through interstellar medium at supersonic velocities. Bow shocks have been detected in the mid-infrared for several high-mass runaway stars and in radio waves for one star. Theoretical models predict the production of high-energy photons by non-thermal radiative processes in a number sufficiently large to be detected in X-rays. To date, no stellar bow shock has been detected at such energies. We present the first detection of X-ray emission from a bow shock produced by a runaway star. The star is AE Aur, which was likely expelled from its birthplace by the encounter of two massive binary systems and now is passing through the dense nebula IC 405. The X-ray emission from the bow shock is detected at 30 to the northeast of the star, coinciding with an enhancement in the density of the nebula. From the analysis of the observed X-ray spectrum of the source and our theoretical emission model, we confirm that the X-ray emission is produced mainly by inverse Compton upscattering of infrared photons from dust in the shock front.