 After the Roman conquest it lost importance, regaining it in the Middle Ages when several castles were built here, being unified into a single town in 1096.In 1205 it was a free commune, existing in particular rivalry with Fermo and against Francesco Sforza.In 1571 it was given the status of City and that of diocesan see by Pope Pius V. After the Renaissance it was part of the Papal States, becoming part of unified Italy in 1860.