The line was opened from Gallarate to Varese on 26 September 1865;[2] in 1885 it went to the state network Rete Mediterranea, operated by the Società per le Strade Ferrate del Mediterraneo.
In 1894 the Società per le Strade Ferrate del Mediterraneo extended the line from Varese to Porto Ceresio,[2] through a beloved touristic area until the shore of Lake Lugano.
In 1899 the line was chosen for an experimental electrification with a third rail at 650 V DC, put into service in 1901–1902.
[3] From 1905 the line was operated by the new state railway company, the Ferrovie dello Stato;[3] but between 1908 and 1918 the section from Varese to Porto Ceresio, that had been built by the Società per le Strade Ferrate del Mediterraneo, was given back to that society.
[6] Since December 2004 the section from Gallarate to Varese is used by the trains of the line S5 of Milan suburban railway service.