Pain is a complex emotional experience that still remains challenging to manage. Previous functional magnetic resonance imaging (fMRI) studies have associated pain with distributed patterns of brain activity (i.e. brain decoders), but it is still unclear whether these observations reflect causal mechanisms. To address this question, we devised a new neurofeedback approach using real-time decoding of fMRI data to test if modulating pain-related multivoxel fMRI patterns could lead to changes in subjective pain experience. We first showed that subjective pain ratings can indeed be accurately predicted using a real-time decoding approach based on the stimulus intensity independent pain signature (SIIPS) and the neurologic pain signature (NPS). Next, we trained participants (n = 16) in a double-blinded decoded fMRI neurofeedback experiment to up- or downregulate the SIIPS. Our results indicate that participants can learn to downregulate the expression of SIIPS independently from NPS expression. Importantly, the success of this neurofeedback training was associated with the perceived intensity of painful stimulation following the intervention. Taken together, these results indicate that closed-loop brain imaging can be efficiently conducted using a priori fMRI decoders of pain, potentially opening up a new range of applications for decoded neurofeedback, both for clinical and basic science purposes. This article is part of the theme issue 'Neurofeedback: new territories and neurocognitive mechanisms of endogenous neuromodulation'.