Using a novel trait-based measure, we examined genetic variants associated with obsessive-compulsive (OC) traits and tested whether OC traits and obsessive-compulsive disorder (OCD) shared genetic risk. We conducted a genome-wide association analysis (GWAS) of OC traits using the Toronto Obsessive-Compulsive Scale (TOCS) in 5018 unrelated Caucasian children and adolescents from the community (Spit for Science sample). We tested the hypothesis that genetic variants associated with OC traits from the community would be associated with clinical OCD using a meta-analysis of all currently available OCD cases. Shared genetic risk was examined between OC traits and OCD in the respective samples using polygenic risk score and genetic correlation analyses. A locus tagged by rs7856850 in an intron of PTPRD (protein tyrosine phosphatase δ) was significantly associated with OC traits at the genome-wide significance level (p = 2.48 × 10-8). rs7856850 was also associated with OCD in a meta-analysis of OCD case/control genome-wide datasets (p = 0.0069). The direction of effect was the same as in the community sample. Polygenic risk scores from OC traits were significantly associated with OCD in case/control datasets and vice versa (p's < 0.01). OC traits were highly, but not significantly, genetically correlated with OCD (rg = 0.71, p = 0.062). We report the first validated genome-wide significant variant for OC traits in PTPRD, downstream of the most significant locus in a previous OCD GWAS. OC traits measured in the community sample shared genetic risk with OCD case/control status. Our results demonstrate the feasibility and power of using trait-based approaches in community samples for genetic discovery.