According to some Roman sources, while on his way to the garden of the Hesperides on the island of Erytheia, Hercules had to cross the mountain that was once Atlas. Instead of climbing the great mountain, Hercules used his superhuman strength to smash through it. By doing so, he connected the Atlantic Ocean to the Mediterranean Sea and formed the Strait of Gibraltar. One part of the split mountain is Gibraltar and the other is either Monte Hacho or Jebel Musa. These two mountains taken together have since then been known as the 'Pillars of Hercules', though other natural features have been associated with the name.

Diodorus Siculus, however, held that instead of smashing through an isthmus to create the Straits of Gibraltar, Hercules narrowed an already existing strait to prevent monsters from the Atlantic Ocean from entering the Mediterranean Sea. In some versions, Heracles instead built the two to hold the sky away from the earth, liberating Atlas from his damnation.

More Info: en.wikipedia.org