Traces of human presence in the area date to the 6th-5th centuries BC. The current town was however founded in the 5th-6th centuries AD as Massa di S. Ambrogio. Starting from the 10th century, there were fortifications and castles, whence the toponym Castrum Rivi from which the current name derives. In 1076 the castle was acquired by Matilde of Canossa; later Emperor Otto IV gave the fief to the Alidosi family, who held it for more than four centuries until it became part of the Papal States.
The Fortress Palace, commissioned in the early 16th century by Francesco Alidosi, cardinal and friend of Bramante, to whom some attribute the design.[3] Notable is the Renaissance style court, with sandstone columns and shell-shaped fountains. The edifice now houses the Castel del Rio Town Hall, a library, the Museum of War and of the Gothic Line, and the Museum of the Chestnut Civilization.