The line between Zurich and Baden was opened on 7 August 1847 by the Swiss Northern Railway (German: Schweizerische Nordbahn, SNB).
It was the first line built in Switzerland, except for the line built from Mulhouse to Basel by the French company, Strasbourg–Basel Railway (French: Chemin de fer de Strasbourg à Bâle), opened to a temporary station outside Basel's walls on 15 June 1844 and to the permanent station on 11 December 1845.
In 1837, the Zurich Chamber of Commerce commissioned the engineer Alois Negrelli to investigate the route of such a line.
Although the Aargau parliament passed a law permitting compulsory purchase in November 1840, several shareholders lost their financial guarantees, and the company had to be dissolved in December 1841.
With an assurance that Alois Negrelli would be direct the engineering and that a branch line would be later built from Baden to Lenzburg and Aarau, the Aargau parliament approved the project in July 1845.
Negrelli relocated of the station in Baden to the north side of town, requiring the construction of the 80-meter-long Schlossberg tunnel.
At the end of 1845 the Nordbahn company was founded with a share capital of 20 million francs, in the spring of 1846 construction work started.
Soon after the opening of the line began to be called the "Spanisch-Brötli bahn" ("Spanish bun railway") because the Zurich gentry sent their servants by train to Baden to buy these pastries in order to impress their clients at Sunday morning teas.
The Baden–Aarau railway was opened between Baden and Brugg on 30 September 1856 and extended to Aarau on 15 May 1858, where it met the line from Olten built by the Schweizerische Centralbahn.