There is a need to identify prognostic biomarkers to guide treatment intensification in patients with nonmetastatic castration-resistant prostate cancer (nmCRPC). To examine whether molecular subtypes predict response to apalutamide, using archived primary tumor samples from the randomized, double-blind, phase 3 SPARTAN trial. In this cohort study, gene expression data from 233 archived samples from patients with nmCRPC enrolled in the SPARTAN trial were generated using a human exon microarray. The present analysis was conducted from May 10, 2018, to October 15, 2020. Patients were randomized (2:1) to apalutamide, 240 mg/d, with androgen deprivation therapy (apalutamide+ADT) or placebo+ADT. Patients were stratified into high-risk and low-risk categories for developing metastases based on genomic classifier (GC) scores for high (GC >0.6) and low to average (GC≤0.6) and into basal and luminal subtypes; associations between these molecular subtypes and metastasis-free survival (MFS), overall survival (OS), and progression-free survival 2 (PFS2) were evaluated using Cox proportional hazards regression and Kaplan-Meier analysis. Median age of the 233 included patients was 73 (range, 49-91) years. A total of 116 of 233 patients (50%) in the SPARTAN biomarker subset had high GC scores. Although all patients receiving apalutamide+ADT had improved outcomes, having high GC scores was associated with the greatest improvement in MFS (hazard ratio [HR], 0.21; 95% CI, 0.11-0.40; P < .001), OS (HR, 0.52; 95% CI, 0.29-0.94; P = .03), and PFS2 (HR, 0.39; 95% CI, 0.23-0.67; P = .001) vs placebo+ADT. In total, 152 of 233 patients (65%) had the basal molecular subtype. Although there were no significant differences in MFS, PFS2, or OS between patients with the luminal vs basal subtype in the placebo+ADT arm, patients with the luminal subtype in the apalutamide+ADT arm had a significantly longer MFS (apalutamide+ADT: HR, 0.40; 95% CI, 0.18-0.91; P = .03; placebo+ADT: HR, 0.66; 95% CI, 0.33-1.31; P = .23) compared with patients with basal subtype; similar trends were observed for OS (apalutamide+ADT: HR, 0.50; 95% CI, 0.25-0.98; P = .04; placebo+ADT: HR, 0.78; 95% CI, 0.38-1.60; P = .50), and PFS2 (apalutamide+ADT: HR, 0.71; 95% CI, 0.42-1.22; P = .22; placebo+ADT: HR, 0.72; 95% CI, 0.38-1.39; P = .33). In regression analysis, the luminal-basal subtype score was significantly associated with MFS in patients receiving apalutamide+ADT (HR, 2.65; 95% CI, 1.15-6.08; P = .02), whereas GC score was significantly associated with MFS in placebo+ADT recipients (HR, 2.09; 95% CI, 1.02-4.27; P = .04). The findings of this study suggest that the GC score and basal-luminal subtype derived from archived tumor specimens may be biomarkers of response to apalutamide+ADT in the nmCRPC setting. Although overall, the addition of apalutamide to ADT was beneficial, higher-risk and luminal subtypes appeared to benefit most. Obtaining GC scores may be useful for identifying patients for early treatment intensification with apalutamide, and basal-luminal subtyping may be a beneficial approach for patient selection for further treatment intensification in trials combining novel therapies with apalutamide.