SummaryThe effects of cocaine on microbiota have been scarcely explored. Here, we investigated the gut (GM) and oral (OM) microbiota composition of cocaine use disorder (CUD) patients and the effects of repetitive transcranial magnetic stimulation (rTMS). 16S rRNA sequencing was used to characterize GM and OM, whereas PICRUST2 assessed functional changes in microbial communities, and gas-chromatography was used to evaluate fecal short and medium chain fatty acids. CUD patients reported a significant decrease in alpha diversity and modification of the abundances of several taxa in both GM and OM. Furthermore, many predicted metabolic pathways were differentially expressed in CUD patients’ stool and saliva samples, as well as reduced levels of butyric acid that appear restored to normal amounts after rTMS treatment. In conclusion, CUD patients showed a profound dysbiotic fecal and oral microbiota composition and function and rTMS-induced cocaine abstinence determined the restoration of eubiotic microbiota.