The town rises north-west of Taranto, in the hinterland of the gulf, on the two sides of the canyon of San Marco, with the district called Terra, an ancient borough of narrow lanes, on the one side and Santa Caterina of the other, connected by two high bridges.
The town was founded in the 6th century AD by a group of refugees called Afri, who were granted by the bishop of Taranto a "Massa" that is a very wide expanse of land, situated between the two canyons called Madonna della Scala and San Marco. However archaeological findings show also traces of Neolithic settlements and items of Messapian origin (5th century BC). In 1080 the fiefdom of Massafra came under Norman rule and then in 1269 passed under Charles of Anjou and was united to the Principato of Taranto.
In 1484 it was occupied by the Aragonese army, and Antonio Pisciello was made Baron of the town. In 1497 it was sacked by the French troops of Charles VIII then passed under the Neapolitan Artusio Pappacoda, whose family ruled until 1633, when the feudal rights were purchased by the Carmignano family. 50 years later it came under the Marquis of Oria and Francavilla, and Marquis Michele II promoted agriculture planting olive and fruit trees, and greatly embellished the town renovating the Castle and building the Monastery of St Benedict and the Clock Tower, commissioning works to the best architects and artists of Apulia.