 Later in the Middle Ages the town was under the Marquisses of Gavi, allied with Frederick Barbarossa, who took refuge here after the Battle of Legnano.In 1202 Gavi was sold to the Republic of Genoa.After a parenthesis under the Visconti and France, it returned to Genoa in 1528.