The present research work focused on predicting the electrical conductivity (EC) of surface water in the Upper Ganga basin using four machine learning algorithms: multilayer perceptron (MLP), co-adaptive neuro-fuzzy inference system (CANFIS), random forest (RF), and decision tree (DT). The study also utilized the gamma test for selecting appropriate input and output combinations. The results of the gamma test revealed that total hardness (TH), magnesium (Mg), and chloride (Cl) parameters were suitable input variables for EC prediction. The performance of the models was evaluated using statistical indices such as Percent Bias (PBIAS), correlation coefficient (R), Willmott’s index of agreement (WI), Index of Agreement (PI), root mean square error (RMSE) and Legate-McCabe Index (LMI). Comparing the results of the EC models using these statistical indices, it was observed that the RF model outperformed the other algorithms. During the training period, the RF algorithm has a small positive bias (PBIAS = 0.11) and achieves a high correlation with the observed values (R = 0.956). Additionally, it shows a low RMSE value (360.42), a relatively good coefficient of efficiency (CE = 0.932), PI (0.083), WI (0.908) and LMI (0.083). However, during the testing period, the algorithm’s performance shows a small negative bias (PBIAS = − 0.46) and a good correlation (R = 0.929). The RMSE value decreases significantly (26.57), indicating better accuracy, the coefficient of efficiency remains high (CE = 0.915), PI (0.033), WI (0.965) and LMI (− 0.028). Similarly, the performance of the RF algorithm during the training and testing periods in Prayagraj. During the training period, the RF algorithm shows a PBIAS of 0.50, indicating a small positive bias. It achieves an RMSE of 368.3, R of 0.909, CE of 0.872, PI of 0.015, WI of 0.921, and LMI of 0.083. During the testing period, the RF algorithm demonstrates a slight negative bias with a PBIAS of − 0.06. The RMSE reduces significantly to 24.1, indicating improved accuracy. The algorithm maintains a high correlation (R = 0.903) and a good coefficient of efficiency (CE = 0.878). The index of agreement (PI) increases to 0.035, suggesting a better fit. The WI is 0.960, indicating high accuracy compared to the mean value, while the LMI decreases slightly to − 0.038. Based on the comparative results of the machine learning algorithms, it was concluded that RF performed better than DT, CANFIS, and MLP. The study recommended using the current month’s total hardness (TH), magnesium (Mg), and chloride (Cl) parameters as input variables for multi-ahead forecasting of electrical conductivity (ECt+1, ECt+2, and ECt+3) in future studies in the Upper Ganga basin. The findings also indicated that RF and DT models had superior performance compared to MLP and CANFIS models. These models can be applied for multi-ahead forecasting of monthly electrical conductivity at both Varanasi and Prayagraj stations in the Upper Ganga basin.