Atrazine (ATZ) is a widely used herbicide that can cause serious harm to organisms and ecosystems. An immobilization-free photoelectrochemical (PEC) aptasensor has been herein developed for ATZ based on aptamer molecular gate functionalized mesoporous SiO2@MB controlled release system. Compared with traditional immobilization-based sensors, immobilization-free sensors (IFSs) avoid the modification of the recognition element on the electrode surface. Mesoporous SiO2 with large surface area and good biocompatibility can be used as nanocontainers to stably encapsulate the signal shuttle molecule methylene blue (MB). The bifunctional aptamer (APT) is used not only as the recognition element for ATZ but also as the signal switch to block or release MB. In the presence of ATZ, the specific recognition between ATZ and APT will cause the detachment of APT from the surface of SiO2, thus the molecular gate will open and release MB. Due to pH modulation, the positively charged MB can reach the surface of the negatively charged Ti(III) self-doped TiO2 NTs (Ti(III)–TiO2 NTs) electrode to act as an electron donor, which increases the photocurrent. The immobilization-free aptasensor has shown ultrasensitive detection of ATZ with a wide linear range from 1.0 pM to 100.0 nM and a low detection limit of 0.1 pM. In addition, the sensor has excellent selectivity, stability and anti-interference ability, and has been used in real water sample analysis successfully. This strategy has provided a new idea for the design of advanced immobilization-free PEC sensors for environmental pollutant detection.