Intracortical brain–machine interfaces decode motor commands from neural signals and translate them into actions, enabling movement for paralysed individuals. The subjective sense of agency associated with actions generated via intracortical brain–machine interfaces, the neural mechanisms involved and its clinical relevance are currently unknown. By experimentally manipulating the coherence between decoded motor commands and sensory feedback in a tetraplegic individual using a brain–machine interface, we provide evidence that primary motor cortex processes sensory feedback, sensorimotor conflicts and subjective states of actions generated via the brain–machine interface. Neural signals processing the sense of agency affected the proficiency of the brain–machine interface, underlining the clinical potential of the present approach. These findings show that primary motor cortex encodes information related to action and sensing, but also sensorimotor and subjective agency signals, which in turn are relevant for clinical applications of brain–machine interfaces.