Ammonia synthesized by nitrogen reduction is the most promising new energy material. Photoelectrocatalytic (PEC) nitrogen reduction reaction (NRR) occurs under ambient conditions and is the optimal alternative to the energy-intensive Haber-Bosch method. Here, we report the one-step reaction synthesis of Ti–WO3/SrWO4 as a photocathode for ammonia synthesis. First-principles calculations demonstrate that Ti doping can afford nitrogen-adsorption sites, and Ti3+ undergoes chemical adsorption and becomes a nitrogen-activation site by providing electrons to nitrogen. Under light irradiation, the photogenerated electrons are captured by Ti4+; this is conducive to the activation and regeneration of Ti3+, thus forming a nitrogen fixation cycle and improving the nitrogen fixation yield. At − 0.5 V vs. RHE, the ammonia synthesis efficiency reaches 11.17 μg h-1 cm-2, which is four times that of SrWO4. Furthermore, the high stability and N-gas sensitivity of Ti–WO3/SrWO4 in the NRR indicate that it can be used as an efficient and stable photoelectrocatalyst for ammonia synthesis.