We report on simultaneous X-ray and radio observations of the mode-switching pulsar PSR B0943+10 obtained with the XMM-Newton satellite and the LOFAR, LWA and Arecibo radio telescopes in November 2014. We confirm the synchronous X-ray/radio switching between a radio-bright (B) and a radio-quiet (Q) mode, in which the X-ray flux is a factor ~2.4 higher than in the B-mode. We discovered X-ray pulsations, with pulsed fraction of 38+/-5% (0.5-2 keV), during the B-mode, and confirm their presence in Q-mode, where the pulsed fraction increases with energy from ~20% up to ~65% at 2 keV. We found marginal evidence for an increase in the X-ray pulsed fraction during B-mode on a timescale of hours. The Q-mode X-ray spectrum requires a fit with a two-component model (either a power-law plus blackbody or the sum of two blackbodies), while the B-mode spectrum is well fit by a single blackbody (a single power-law is rejected). With a maximum likelihood analysis, we found that in Q-mode the pulsed emission has a thermal blackbody spectrum with temperature ~3.4x10^6 K and the unpulsed emission is a power-law with photon index ~2.5, while during B-mode both the pulsed and unpulsed emission can be fit by either a blackbody or a power law with similar values of temperature and photon index. A Chandra image shows no evidence for diffuse X-ray emission. These results support a scenario in which both unpulsed non-thermal emission, likely of magnetospheric origin, and pulsed thermal emission from a small polar cap (~1500 m^2) with a strong non-dipolar magnetic field (~10^{14} G), are present during both radio modes and vary in intensity in a correlated way. This is broadly consistent with the predictions of the partially screened gap model and does not necessarily imply global magnetospheric rearrangements to explain the mode switching.