The castle was built by Matteo Visconti in 1290 and later passed to the Savoy. The castle was badly damaged during the Spanish siege in 1638. The castle was later used as a prison before it was converted into the Palace of Justice in 1838.