During the Miocene era, the river's valley was actually an arm of the sea that connected the waters of the Mediterranean with those of the Atlantic Ocean through the Bética depression (now the valley of the Guadalquivir). In the Pliocene, this connection was severed by the creation of the Sierra of Mijas and the Montes de Málaga, while also creating the geologically isolated Sierra of Cártama. Throughout the rest of the Pliocene, the river basin eventually took on its current form.