This work presents a mathematical model for the simultaneous optimisation of water and energy usage in hydraulic fracturing using a continuous time scheduling formulation. The recycling/reuse of fracturing water is achieved through the purification of flowback wastewater using thermally driven membrane distillation (MD). A detailed design model for this technology is incorporated within the water network superstructure in order to allow for the simultaneous optimisation of water, operation, capital cost, and energy used. The study also examines the feasibility of utilising the co-produced gas that is traditionally flared as a potential source of energy for MD. The application of the model results in a 22.42% reduction in freshwater consumption and 23.24% savings in the total cost of freshwater. The membrane thermal energy consumption is in the order of 244 × 10 3 kJ/m 3 of water, which is found to be less than the range of thermal consumption values reported for membrane distillation in the literature. Although the obtained results are not generally applicable to all shale gas plays, the proposed framework and supporting models aid in understanding the potential impact of using scheduling and optimisation techniques to address flowback wastewater management.