Natural disasters greatly threaten our lives in addition to adversely affecting all activities. Unfortunately, most solutions currently used in flood management are suffering from many drawbacks related to latency and accuracy. Moreover, the previous solutions consider that the whole city has the same level of vulnerability to damage, while each area in the city may have different topologies and conditions. This study presents a new framework that collects data in real-time about bad weather, which may cause floods, where the framework has a proposed classification algorithm to process sensed data to determine the level of danger in each area of the city. In case of a threat, the framework will send early alerts to users and rescue teams. The framework depends on the Internet of Things (IoT) and fog computing coupled with multiple models of machine learning (Rain Forest, Decision Tree, K-Nearest Neighbor, Support Vector Machine, Logistic Regression, and Deep Learning) to enhance performance and reliability. In addition, the research suggests some assistant services. To prove the efficiency of the framework, we applied the proposed algorithm to real data for the city of Jeddah, Saudi Arabia, for the years 2009 to 2013 and for the years 2018 to 2022. Then, we depended on standard metrics (accuracy, precision, recall, F1-score, and ROC curve). The Rain Forest and Decision Tree achieved the highest accuracy, exceeding 99 percent, followed by the K-Nearest Neighbor. The framework will provide flood detection systems that can predict floods early, send a multi-level warning, and reduce financial, human, and infrastructural damage.