The first section of the Wehntal railway was opened between Oberglatt and Dielsdorf at 1 May 1865. It was operated by the Bülach-Regensberg-Bahn as a terminal branch line connecting to the main line Bülach-Zürich Oerlikon of the same company. At January 1, 1877 the Bülach-Regensberg-Bahn got bought by the Swiss Northeastern Railway, which made the acquisition to fight a possible competition by the Swiss National Railway by providing a shorter connection between Winterhtur and Baden. The extension of the Wehntal railway till Niederweningen was already planned at the time of the purchase by NOB, but was only realized 1891. During the construction work some bones of Mammoth were found in Niederweningen. The Niederweningen Dorf railway station became the new terminal station which was at that time called Niederweningen. The latest extension of the branch line was realized in 1938, where the line got extended by about one km to connect the agriculture machinery factory Bucher-Guyer to the Swiss railway network. With the opening of the extension the new terminal station was called Niederweningen, while the name of the old terminal station became Niederweningen Dorf.
A further extension of the railway line through the Surb valley was planned since the mid-19th century, but was never realized. With this extension called Surb railway line the Wehntalbahn would have been connected in Döttingen to the Turgi–Koblenz–Waldshut railway line and would have had lost the status as a terminal branch line. The construction of the extension was decided 1916 by amending the Swiss federal law by paragraph SR 742.34, but the construction never started. When the amended paragraph was cancelled 1937, the government had to give in by adapting the Swiss wide ticket prices and fright fares in such a way, that all prices were evaluated if the extension would have been built. The calculation considering the virtual Surb valley railroad only ended somewhere in the seventies.
Electrification
After World War II the Wehntal railway was threatened to be closed due to spares traffic. Some test with railcars were not successful. After it was decided not to close the railway line it was electrified 1960 with 15 kV 16⅔ Hz as the second to last railway line of the Swiss Federal Railways to be electrified. The last railway line to be electrified was the Cadenazzo–Luino railway, which cross the Italian border. There the steam operation lasted only a few weeks longer than on the Wehntal railway line. Since 1990 the Wehntal railway is part of the Zurich S-Bahn. Until the end of 2015 it was operated by routes S5 and S55. Since then it has been operated by route S15.