Obsessive-compulsive disorder (OCD) is a highly prevalent neuropsychiatric disorder poorly controlled with pharmacological treatment because of the wide variation in symptom patterns. We analysed real-world data on adverse self-reports and insurance claims to identify a novel therapeutic target for OCD. We found that dopamine D2 receptor (D2R) agonists increased the incidence of OCD-like symptoms, which were suppressed by the concomitant use of proton pump inhibitors (PPIs). Further, OCD-like repetitive and habitual behaviours were observed in mice repeatedly injected with a D2R agonist, quinpirole. However, these abnormalities were suppressed by short-term PPI treatment. In quinpirole-treated mice, PPI inhibited pyramidal neuron hyperactivity in the lateral orbitofrontal cortex, a region where the P-type proton pump gene Atp4a is abundantly expressed. In primary cultured cortical neurons, short-term PPI treatment lowered intracellular pH and decreased firing activity, which was mimicked by Atp4a knockdown. Our findings show that inhibition of P-type proton pumps may be a novel therapeutic strategy for OCD.