The MEG (Mu to Electron Gamma) experiment has been running at the Paul Scherrer Institut (PSI), Switzerland since 2008 to search for the decay meg by using one of the most intense continuous $mu^+$ beams in the world. This paper presents the MEG components: the positron spectrometer, including a thin target, a superconducting magnet, a set of drift chambers for measuring the muon decay vertex and the positron momentum, a timing counter for measuring the positron time, and a liquid xenon detector for measuring the photon energy, position and time. The trigger system, the read-out electronics and the data acquisition system are also presented in detail. The paper is completed with a description of the equipment and techniques developed for the calibration in time and energy and the simulation of the whole apparatus.