The Messinian salinity crisis (5.96 to 5.33 million years ago) was caused by reduced water inflow from the Atlantic Ocean to the Mediterranean Sea resulting in widespread salt precipitation and a decrease in Mediterranean sea level of about 1.5 kilometres due to evaporation. The reduced connectivity between the Atlantic and the Mediterranean at the time of the salinity crisis is thought to have resulted from tectonic uplift of the Gibraltar arc seaway and global sea-level changes, both of which control the inflow of water required to compensate for the hydrological deficit of the Mediterranean. However, the different timescales on which tectonic uplift and changes in sea level occur are difficult to reconcile with the long duration of the shallow connection between the Mediterranean and the Atlantic needed to explain the large amount of salt precipitated. Here we use numerical modelling to show that seaway erosion caused by the Atlantic inflow could sustain such a shallow connection between the Atlantic and the Mediterranean by counteracting tectonic uplift. The erosion and uplift rates required are consistent with previous mountain erosion studies, with the present altitude of marine sediments in the Gibraltar arc and with geodynamic models suggesting a lithospheric slab tear underneath the region. The moderate Mediterranean sea-level drawdown during the early stages of the Messinian salinity crisis can be explained by an uplift of a few millimetres per year counteracted by similar rates of erosion due to Atlantic inflow. Our findings suggest that the competition between uplift and erosion can result in harmonic coupling between erosion and the Mediterranean sea level, providing an alternative mechanism for the cyclicity observed in early salt precipitation deposits and calling into question previous ideas regarding the timing of the events that occurred during the Messinian salinity crisis.