The old pulsar PSR B0943+10 ( P =1.1 s , characteristic age \tau =5 Myr ) is the best example of mode-switching radio pulsar . Its radio emission alternates between a highly organised state with regular drifting subpulses ( B mode ) and a chaotic emission pattern ( Q mode ) . We present the results of XMM-Newton observations showing that the X-ray properties of PSR B0943+10 depend on its radio state ( ) . During the radio fainter state ( Q mode ) the X-ray flux is more than a factor two larger than during the B-mode and X-ray pulsations with \sim 50 % pulsed fraction are detected . The X-ray emission of PSR B0943+10 in the B-mode is well described by thermal emission with blackbody temperature kT =0.26 keV coming from a small hot spot with luminosity of 7 \times 10 ^ { 28 } erg s ^ { -1 } , in good agreement with the prediction of the partially screened gap model , which also explains the properties of the radio emission in this mode . We derived an upper limit of 46 % on the X-ray pulsed fraction in the B-mode , consistent with the geometry and viewing angle of PSR B0943+10 inferred from the radio data . The higher flux observed during the Q-mode is consistent with the appearance of an additional component with a power-law spectrum with photon index 2.2 . We interpret it as pulsed non-thermal X-rays produced in the star magnetosphere . A small change in the beaming pattern or in the efficiency of acceleration of the particles responsible for the non-thermal emission can explain the reduced flux of this component during the radio B-mode .