The region around Ostuni has been inhabited since the Stone age. The town is reputed to have been originally established by the Messapii, a pre-classic tribe, and destroyed by Hannibal during the Punic Wars. It was then re-built by the Greeks, the name Ostuni deriving from the Greek Astu néon ("new town").

Sacked after the fall of the Western Roman Empire, in 996 AD the town became part of the Norman County of Lecce .The Normans built their medieval town around the summit of the hill (229 m), with a castle (only remains can be seen) and city walls with four gates. From 1300 to 1463 it was part of the Principality of Taranto and from 1507 (together with what is now the frazione of Villanova and Grottaglie) passed to Isabella, Duchess of Bari, wife of Gian Galeazzo Sforza, Duke of Milan. Under Isabella's rule, Ostuni thrived during the Italian Renaissance. Isabella protected humanists and people of art and letters, including bishop Giovanni Bovio. She died in 1524 and Ostuni passed as a dowry to her daughter Bona Sforza, wife-to-be of Sigismund I of Poland, King of Poland. During Bona Sforza's government, Ostuni continued to enjoy a stable rule. In 1539 she had towers built along all the shoreline as protection against anticipated attacks from Turks who controlled the Balkans. These towers (still extant, including Pozzella Tower, the Pylon, Villanova and others), were garrisoned and communicated using fiery beacons.

Ostuni is built on three hills and is a perfect example of Pugliese town architecture. Its stratified shape exhibits the different stages of architecture added by each ruling civilization.