BiOBr x I 1−x /Ti 3 C 2 Schottky heterojunction nanocomposites were prepared through a simple electrostatic adsorption and self-assembly method. The Schottky heterojunction was used as a sensitive material in the fabrication of a photoelectrochemical (PEC) sensor for mercury ion detection. Due to the large specific surface area, excellent electrical conductivity, and abundant surface chemical groups of the 2D nano Ti 3 C 2 in the Schottky heterojunction, the in situ growth of solid solution BiOBr x I 1−x on its surface enabled the nanocomposites to form a high Schottky barrier to improve the sensitivity of the PEC response. The addition of glutathione (GSH) caused it to adhere to the surface of the nanocomposites where it hindered the transfer of electrons and reducing the photocurrent by reacting with the bismuth ions on their surface through its carboxyl groups. During the Hg 2+ assay, Hg 2+ ions reacted to GSH on the surface of the heterojunction nanocomposites, and then captured more GSH in a solution to form a complex with 3D structure. This complex further hindered electron transfer and led to a sharp decrease in photocurrent. A trace amount of Hg 2+ was detected based on the change of photocurrent, with a linear range of 1.0 × 10 −10 mol/L to 1.0 × 10 −6 mol/L and a detection limit of 4.21 × 10 −11 mol/L. This method was one of the most sensitive methods reported for Hg 2+ detection. The sensor had been applied to determine trace mercury in environmental water samples.