One tends to forget the peasant republics that were if not common, at least not unheard of in northern Europe and Scandinavia.
Gotland (not including Visby), conquered by the Danish King Valdemar 1361 nominally owed allegiance to the Swedish King, but had no duties for it - they did not have to pay taxes, raise troops or provide for royal officials. They raised their own militia and established their own laws at the thing. They were a peasant republic.
Jämtland, ruled through its thing, the Jamtamot was a peasant republic until conquered by Sverre Sigurdsson (who would become King of Norway 1184) 1178.
Dithmarschen, a peasant republic along the German North Sea coast remained independent from at least 1180 to 1559.
Switzerland, as the Old Swiss Confederacy, or Oath Fellowship, was a peasant and burgher republic established around 1300 that lasted until the French revolutionary invasion 1798.
Opstalboom League, a Frisian Republic of burghers, peasants and minor nobility lasted for a few years during thr 14th cntury.
Your question is very interesting, and it is a research topic that I have looked into a lot. Here I have answered it to the best of my understanding.
After Charlemagne's conquest of the Lombard Kingdom in 774, Northern Italy was divided among several Ducal Families, mirroring the feudal structure in the rest of Europe. Among these, we should remember the House of Obertenghi (later called the House of Este) dukes of Lombardy, the House of Savoy, ruling most of northwestern Italy, the House of Sambonifacio, who were Marquis of Verona, and the House of Canossa, Marquis of Tuscany.
However, these feudal lords took less than three hundred years to become irrelevant. Unlike France, Spain, Germany, and England, Italy was extremely densely populated. This made it easier to reconstruct the cities destroyed after the fall of the Roman Empire. The density of cities fostered trade, and the proliferation of trade made it so that the wealthy cities could soon offer better protection than local lords, attracting many new residents, and winning the allegiance of small landholders.
Soon, the local lords became irrelevant. By the Year 1000, the cities of Crema, Cremona, Milan, Monza, Bergamo and Brescia were all thriving "Republics", and the House of Obertenghi, who should of ruled over them, was all but unknown! The Obertenghi controlled only their castle at Este, and indeed, soon came to be known as the House of Este (they later became involved in local politics in the city of Ferrara, more on that later).
In the cities, many families became rich from trade, and all of these families demanded a say in government. Hence, the "Republican" form of government. Some rich families started out as local counts, and then moved to the city to invest and multiply their fortune. The prime example is the Ezzellini family, who were minor landholders outside Treviso. Shrewd investment led them to be one of the most important families of the 12th century, and they were key members in the local council in the cities of Vicenza and Treviso. Similarly, the families of Carogna, Baggio and Busto held small castles outside Milan. In the 11th century they moved to the city to invest their small fortunes, and eventually became key players in local politics. Even if not everyone who moved to the city was as successful as these families, many local lords saw the City as their point of reference, not their overlords, who were for the most part forgotten.
The rest is history: Cities would expand their territory, dominating other cities in the process. Milan, Florence, and Verona gained reputations as the "Bully" cities in Italy, amassing vast territory and subjugating many surrounding cities. Eventually, a single family would dominate the others, and the republic would be topped. The prime example is Milan, where the Visconti toppled the local republic as early as the 13th century. In Verona, the Scaligeri family performed a similar coup in the early 14th century, as did the Carrara in Padua.
A surprisingly late example was Florence, where the Medici only openly declared themselves as the sole rulers in the early 16th century, after they had been pulling the strings behind the scenes for decades. By this time, Florence had conquered the neighboring republics of Pisa and Siena.
edit: typos
The answer to this question goes back further than the other contributors seem to realize, and although the communes did not become a widespread mode of urban political organization before the 11th century, the institution has its roots in the Lombard period. For Italy and her Lombard rulers, cities maintained a symbolic importance to elite life. Even as the Roman Empire was falling apart in the west, and we can point to a demonstrable decline in Italian city life, the Lombard elites clung to city life as the refined ideal for an aristocrat. For a literary example of this, we might recognize the fact that panegyric poetry, written in honor of specific cities such as Milan, continued to be an incredibly popular literary form.
The symbolic importance of cities became very real during the seventh century. Trade began to once again pick up and the cities of Tuscany and the Po valley (I'd include Venice here as well, but it's a different animal that should be discussed with Amalfi rather than the other Lombard cities at this early date) began to establish connections with not only northern Europe, but the eastern Mediterranean as well. While this revitalization was by no means close to equalling levels of commerce that must have existed in the Roman period, it did give the cities of northern Italy a concrete basis for their importance within the Lombard state.
This meant that, "The inhabitants of the towns constituted active political bodies which could collectively guard and protect their own interests, take part in the internal politics of the kingdoms, or raise an army. They could even oppose the local holders of public authority, the iudices of the royal administration (Paolo Delogu, from his essay in The New Cambridge Medieval History: Volume 2, 700-900)."
It was also during the Lombard period that the bishops of Italian cities began to centralize their spiritual and temporal power over the rural churches in the countryside. While this might not seem that important to the rise of the Italian commune, many of these political entities were closely linked to their local bishop. As O.P. Augustine Thompson has shown in his wonderful book, Cities of God, the prestige of the Italian bishoprics helped the early Italian communes to legitimize their authority. One of the most interesting examples of this can be found in Genoa. The oath that all citizens had to take was often called the Bishop's oath and could be sworn in a state building or the cathedral.
From all this, we can see the growth of urban centers as legitimate centers of independent power before the Carolingian invasions. It was only natural for these processes to continue to develop as the successors to Charlemagne failed to achieve an aristocratic consensus and the kings north of the Alps, such as Conrad II, were unable to maintain Italy as a part of a larger European Empire.