The formation of unwanted oil emulsions during producing, transporting, and processing crude oils is a major challenging issue, which causes serious technical problems, and subsequently huge financial losses. The present work delves into an optimization study focused on water separation from crude oil emulsions. The separation performance was initially assessed in static conditions through bottle tests, followed by a thorough investigation in dynamic conditions on an electrostatic desalting pilot plant under various conditions of the main operating parameters: temperature, oil space velocity, wash water ratio, and demulsifier concentration. The design of experiments and optimization of the process were performed by Central-Composite-Design of Response-Surface-Methodology (CCD-RSM). The effectiveness of the separation process has been analyzed by evaluating the Water-Removal-Efficiency (WRE) and Salt-Removal-Efficiency (SRE). The obtained results demonstrated that the used demulsifier was found to be extremely efficient and to have the greatest impact on the dehydration efficiency (F-value = 434.56). In addition, the sensitivity analysis indicated that the dehydration/desalting process is also very sensitive to the oil space velocity and wash water ratio while having less sensitivity to changes in the temperature. Furthermore, the process optimization indicated that the highest efficiency of simultaneous removal of water and salt from crude oil (WRE = 94.54 % and SRE = 97.23 %) was observed at optimal conditions of 19.5 ppm demulsifier concentration, 125 °C temperature, 1 1/h oil space velocity, and 6 vol% wash water ratio.