Since the 6th century Bergamo has been the seat of one of the most important Lombard duchies in northern Italy, together with Trento, Brescia and Cividale dei Friuli.
From the 11th century onwards, Bergamo was an independent commune, taking part in the Lombard League which in 1165 defeated Frederick I Barbarossa.
After a short period under the rule of the House of Malatesta, Bergamo was ceded in 1428 by the Duchy of Milan to the Republic of Venice in the context of the Wars in Lombardy and the aftermath of the 1427 Battle of Maclodio.
The uneasy balance of power between the Northern Italian states precipitated the Italian Wars, a series of conflicts from 1494 to 1559 that involved, in different time, also the Papal States, France and the Holy Roman Empire. The wars, which were both a result and cause of Venetian involvement in the power politics of mainland Italy, prompted Venice to assert its direct rule over its mainland domains.
On 17 October 1797 the Treaty of Campo Formio formally recognized the inclusion of Bergamo and other parts of Northern Italy into the Cisalpine Republic.
In 1815 the Congress of Vienna assigned Bergamo to the Kingdom of Lombardy-Venetia, a crown land of the Austrian Empire. The visit of Emperor Ferdinand I in 1838 coincided with the opening of the new boulevard, leading to the railway station that was inaugurated in 1857.
In 1859 Giuseppe Garibaldi conquered Bergamo, during the Second Italian War of Independence. As a consequence the city became part of the newly-proclaimed Kingdom of Italy founded in 1861.
Due to its contribution to the Italian unification movement, Bergamo was named La Città dei Mille (City of the Thousand), due to the city's support for Giuseppe Garibaldi in his 1860 Expedition of the Thousand against the Kingdom of the Two Sicilies. During the 20th century, Bergamo became one of Italy's most industrialized areas.