We report the observation of the ratchet effect for a relativistic flux quantum trapped in an annular Josephson junction embedded in an inhomogeneous magnetic field. In such a solid state system, mechanical quantities are proportional to electrical quantities, so that the ratchet effect represents the realization of a relativistic-flux-quantum-based diode. Mean static voltage response, equivalent to directed fluxon motion, is experimentally demonstrated in such a diode for deterministic as well as stochastic oscillating current forcing.