The origin of present-day Montalcino can be traced back to the 9th to 10th centuries, when the sackings and invasions of the Saracens against the maritime cities of the Tyrrhenian coast drove their inhabitants to seek a safer haven inland. From the twelfth century onward, Montalcino was already an autonomous commune, but for a long time, at least until the Renaissance period, it was contested between the Florentine and Sienese spheres of influence, and moments of high tension alternated periods of relative calm and well-being. In the middle years of the 14th century, it fell under the control of Siena. In 1462 it was raised to the rank of a city, and was made a diocese together with Pienza by Pope Pius II. In 1553 Montalcino suffered the last great siege in its history, at the hands of the Imperial and Medicean forces, and in 1553, after the surrender of Siena to the Medici, it became the seat of the exiled republican government of Siena, which held out until 1559.