The territory of the country includes most of the crater of Vesuvius. The Medici Castle in Ottaviano houses the headquarters of the National Park of Vesuvius.
Ottaviano was in Roman times a hamlet of houses within a vast estate (praedium Octaviorum) belonging to the gens Octavia, Augustus's family. The territory was the scene of a battle between Lucius Cornelius Sulla and Lucius Cluentius in 90 BC, during the Social War. On the territory of Ottaviano, during the Third Servile War, in 73 BC, Spartacus defeated the force stationed there.
The village (called Octavianum) grew in importance, becoming a municipality. According to some historians, it was here that the Emperor Augustus actually died, his body then being moved to Nola. The remains of the Roman era were buried by successive eruptions of Vesuvius, but the ruins and tombs have been unearthed in excavations in various parts of the country.
In 1085, Pope Gregory VII visited the city and celebrated mass in a church (church of Vaglio) located at the baronial castle (today the Palazzo Mediceo). Several lords and barons held the city in this period. In the 13th century it was in the possession of Thomas Aquinas, the grandfather of Saint Thomas Aquinas. During the Angevin rule of Naples, in 1304, the village was put to fire and sword by Carlo di Lagonessa by order of king Charles II, because of the killing of a regional officer ("superintendent of the woods") and his escort by the brothers John and Roberto de Marrone.
Between 1532 and 1551 it was the fief of Fabrizio Maramaldo, who had obtained it through services rendered to Charles V. The fief was then transferred to the Gonzaga of Molfetta and after, in 1567, to Bernadetto de' Medici, cousin of the Grand Duke Cosimo de' Medici. The fief remained in possession of this family until 1860 and also included the current municipalities of Terzigno and San Giuseppe Vesuviano. Of the de' Medici family was part Luigi de' Medici, the representative of the Kingdom of Naples at the Congress of Vienna.
The city has long suffered from eruptions of Vesuvius, and in particular was almost completely buried by volcanic ash from Vesuvius's eruption of 1631, 1779 and 1906. According to Sir William Hamilton, during the first and second eruptions Ottaviano "was buried like Pompeii", and also in the third, as testified by Matilde Serao, who called the city "the new Pompeii". In the third eruption also the roof of the Mother Church of San Michele Arcangelo collapsed under the weight of the ash, fortunately without killing anyone.