In arid and semi-arid areas where agriculture competes keenly with ecosystem for water, integrated management of both surface water (SW) and groundwater (GW) resources at a basin scale is crucial, but often lacks scientific support. This study implemented physically-based, fully integrated SW–GW modeling in optimizing water management, and performed surrogate modeling to replace the computationally expensive model with simple response surfaces. Water use conflicts between agriculture and ecosystem in Heihe River Basin (HRB), the second largest inland river basin in China, were investigated. Based on the integrated model GSFLOW (Coupled Ground-Water and Surface-Water Flow Model), the conjunctive use of SW and GW for irrigation in the study area was optimized using a surrogate-based approach named DYCORS (DYnamic COordinate search using Response Surface models). Overall, the study demonstrated that, with the surrogate modeling approach, an expensive integrated model could be efficiently incorporated into an optimization analysis, and the integrated modeling would make feasible a physically based interpretation of the optimization results. In the HRB case study, the surrogate-based optimization suggested a very different time schedule of water diversion in opposite to the existing one, indicating the critical role of SW–GW interactions in the water cycle. With the temporal optimization, a basin-scale water saving could be achieved by reducing non-beneficial evapotranspiration. In addition, the current flow regulation in HRB may not be sustainable, because the ecosystem recovery in the lower HRB would be at the cost of the ecosystem degradation in the middle HRB.