ZnO thin films are deposited in pure Ar and mixed Ar and N2 gas ambient at substrate temperature of 500°C by rf sputtering ZnO targets. All the films were deposited on fluorine doped tin oxide coated glass. We find that the presence of optimum N2 to Ar ratio in the deposition ambient promotes the formation of well aligned ZnO nanorods. ZnO thin films grown at 25 % N2 gas flow rate promoted aligned nanorods along c-axis exhibit significantly enhanced photoelectrochemical response, as compared to ZnO thin films grown at other N2 to Ar gas flow ratios. Our results suggest that chamber ambient is very important for the formation of aligned nanostructures, which offer potential advantages for improving the efficiency of photoelectrochemical water splitting for H2 production.