Optimizing urban water distribution systems is essential for reducing economic losses, minimizing water wastage, and addressing resource access gaps, particularly in drought-prone regions impacted by climate change. We apply advanced artificial intelligence (AI) techniques and the Internet of Things (IoT) to optimize water networks in Spain using simulation. By employing EPANET for hydraulic modeling and a linear regression-based algorithm for optimization, we achieved up to 96.62% system efficiency with a mean absolute error of 0.049. Our approach demonstrates the potential to conserve up to 648,000 L of water daily at high-demand nodes, contributing to substantial resource savings across urban water networks. We propose a global architecture utilizing Low Power Wide Area Network and Low Earth Orbit solutions for widespread deployment. This study underscores the potential of AI in water network optimization and suggests future research avenues for implementing the proposed architecture in real urban water systems.