Venice was an independent state for almost a millennium, but it might note have been. It all hinged on a single battle fought in the Venetian lagoon in 810.
In late Antiquity the north-east of the Italian peninsula suffered many invasions. The wars caused people to move to the safer lagoon areas, and hence to the foundation of Venice.
Recently discovered frescoes in the church of Torcello, former seat of the bishop, attest the close connections early Venice had to the Caroligian empire.