Obsessive-compulsive disorder (OCD) is a common psychiatric disorder with a lifetime prevalence of 2-3%. Recently, brain activity in the resting state is gathering attention for exploring altered functional connectivity in psychiatric disorders. Although previous resting-state functional magnetic resonance imaging studies investigated the neurobiological abnormalities of patients with OCD, there are concerns that should be addressed. One concern is the validity of the hypothesis employed. Most studies used seed-based analysis of the fronto-striatal circuit, despite the potential for abnormalities in other regions. A hypothesis-free study is a promising approach in such a case, while it requires researchers to handle a dataset with large dimensions. Another concern is the reliability of biomarkers derived from a single dataset, which may be influenced by cohort-specific features. Here, our machine learning algorithm identified an OCD biomarker that achieves high accuracy for an internal dataset (AUC = 0.81; N = 108) and demonstrates generalizability to an external dataset (AUC = 0.70; N = 28). Our biomarker was unaffected by medication status, and the functional networks contributing to the biomarker were distributed widely, including the frontoparietal and default mode networks. Our biomarker has the potential to deepen our understanding of OCD and to be applied clinically.