The Strait of Gibraltar is a narrow opening that separates the continent of Africa from Europe; it is also the only point where the Mediterranean Sea connects to the Atlantic Ocean, and therefore an important passageway for sea travel to the west of the Iberian Peninsula, Africa, and beyond.
According to Strabo (3.5.5), Hercules raised the Pillars during one of his Twelve Labours to mark the western edge of the inhabited world. One pillar was identified as the Rock of Gibraltar (called Mount Calpe in ancient times), with the other was Ceuta (Mount Abile) on the African side of the narrow strait.
Diodorus Siculus mentions that Hercules put the Pillars in place as a monument to himself (4.18.4). He also adds that Hercules either narrowed the passage in order to prevent sea-monsters from the Atlantic to enter the Mediterranean, or to actually open the mountain so that the Atlantic could mingle with the Mediterranean. On this issue, as Diodorus puts it, “it will be possible for every man to think as he may please” (4.18.5).
Roman writers like Pliny and Seneca seem to have preferred the version where Hercules smashed an existing mountain to create the Straits of Gibraltar. The mountain that he splits is taken by some to have once been the god Atlas, turned to stone by Perseus wielding the head of the gorgon Medusa.