The spatial resolution of magnetoencephalography (MEG) can be increased from that of conventional SQUID-based systems by employing on-scalp sensor arrays of e.g. optically-pumped magnetometers (OPMs). However, OPMs reach sufficient sensitivity for neuromagnetic measurements only when operated in a very low absolute magnetic field of few nanoteslas or less, usually not reached in a typical magnetically shielded room constructed for SQUID-based MEG. Moreover, field drifts affect the calibration of OPMs. Static and dynamic suppression of interfering fields is thus necessary for good-quality neuromagnetic measurements with OPMs. Here, we describe an on-scalp MEG system that utilizes OPMs and external compensation coils that provide static and dynamic shielding against ambient fields. In a conventional two-layer magnetically shielded room, our coil system reduced the maximum remanent DC-field component within an 8-channel OPM array from 70 to less than 1 nT, enabling the sensors to operate in the sensitive spin exchange relaxation-free regime. When compensating field drifts below 4 Hz, a low-frequency shielding factor of 22 dB was achieved, which reduced the peak-to-peak drift from 1.3 to 0.4 nT and thereby the standard deviation of the sensor calibration from 1.7% to 0.5%. Without band-limiting the field that was compensated, a low-frequency shielding factor of 43 dB was achieved. We validated the system by measuring brain responses to electric stimulation of the median nerve. With dynamic shielding and digital interference suppression methods, single-trial somatosensory evoked responses could be detected. Our results advance the deployment of OPM-based on-scalp MEG in lighter magnetic shields.