The production of shale gas and oil is associated with the generation of substantial amounts of wastewater. With the growing emphasis on sustainable development, the energy sector has been intensifying efforts to manage water resources while diversifying the energy portfolio used in treating wastewater to include fossil and renewable energy. The nexus of water and energy introduces complexity in the optimization of the water management systems. Furthermore, the uncertainty in the data for energy (e.g., solar intensity) and cost (e.g., price fluctuation) introduce additional complexities. The objective of this work is to develop a novel framework for the optimizing wastewater treatment and water-management systems in shale gas production while incorporating fossil and solar energy and accounting for uncertainties. Solar energy is utilized via collection, recovery, storage, and dispatch of heat. Heat integration with an adjacent industrial facility is considered. Additionally, electric power production is intended to supply a reverse osmosis (RO) plant and the local electric grid. The optimization problem is formulated as a multi-scenario mixed integer non-linear programming (MINLP) problem that is a deterministic equivalent of a two-stage stochastic programming model for handling uncertainty in operational conditions through a finite set of scenarios. The results show the capability of the system to address water-energy nexus problems in shale gas production based on the system’s economic and environmental merits. A case study for Eagle Ford Basin in Texas is solved by enabling effective water treatment and energy management strategies to attain the maximum annual profit of the entire system while achieving minimum environmental impact.