People have lived on this shore since the Stone Age. Etruscan monuments from the 5th to 2nd centuries BC have turned up at Davesco-Soragno, Pregassona and Viganello, all now parts of the city. The Romans settled the area by the 1st century BC, but their main town was at Bioggio, north of Lugano. The name appears in writing in 804, and by 984 Lugano was described as a market town.
For centuries the town was a prize in a fight between Como and Milan, whose ruling families, the Rusca and the Visconti, kept taking it from each other. Ludovico Sforza built a castle on the plain of the Cassarate. Swiss forces besieged it twice and began pulling it down in 1517. Lugano had become a Swiss dominion in 1513, and it stayed one for nearly three centuries.
Under Swiss rule, the von Beroldingen family from Uri supplied the bailiff's chancellors for more than two centuries. One of them built Palazzo Beroldingen where Parco Ciani now lies, and Villa Favorita in Castagnola. In 1746 the Agnelli brothers opened Lugano's first printing press. Their newspaper became the first in Italian to print an excerpt of the American Declaration of Independence. It stopped in 1799 when rioters sacked the press and the abbot Vanelli was shot.
Napoleon ended Swiss control in 1798 and made Lugano the capital of its own canton. It lasted only until 1803, when the canton merged with Bellinzona to form Ticino. Lugano then shared the role of capital with Bellinzona and Locarno on a six-year rotation. The city hall was built in 1843 and 1844, housed the cantonal government from 1845 to 1851 and again from 1863 to 1869, and has housed the city government since 1890. Lugano is called Ticino's unofficial capital, though the cantonal government sits in Bellinzona.
Rail made modern Lugano. The station opened in 1877 and the Gotthard line in 1882, tying the town to northern Italy and the rest of Europe. Visitors followed. Between 1880 and 1910 the population more than doubled, and by 1910 foreign nationals made up 43.6% of residents. The first part of the lakefront promenade dates from the 1870s.
After the Second World War, money flowed in from Italy and the banks multiplied. Lugano became Switzerland's third financial centre, with more than 100 banks. In 1956 the Teatro Kursaal hosted the first Eurovision Song Contest. Since 2004, mergers with a string of neighbouring villages, Gandria among them, have brought the population to 63,691 as of 2025.