The sensitive and accurate detection of ochratoxin A (OTA) is crucial for public health due to its high toxicity. Herein, using Au nanoparticle (NP)-attached CdS/UiO-66-NH 2 heterostructures as photoactive materials, a photoelectrochemical (PEC) aptasensor was presented for the ultrasensitive assay of OTA based on a competitive displacement reaction triggering the trans-cleavage ability of CRISPR/Cas12a. In this sensing strategy, methylene blue-labeled single-stranded DNA (MB-ssDNA) was immobilized on the Au NPs/CdS/UiO-66-NH 2 electrode to accelerate the separation of the photogenerated carrier, thus producing a significantly increased PEC response. In the presence of OTA, it specifically bound with the aptamer (Apt) and resulted in the release of the activation chain, triggering the trans-cleavage characteristics of CRISPR/Cas12a. MB-ssDNA was cut randomly on the electrode surface to convert the PEC signal from the "on" to the "off" state, thereby achieving a quantitative and accurate detection of OTA. The CRISPR/Cas12a-derived PEC aptasensor exhibited excellent sensitivity and specificity, with a linear range from 100 to 50 ng/mL and a detection limit of 38 fg/mL. Overall, the proposed aptasensor could provide a rapid, accurate, and sensitive method for the determination of OTA in actual samples.