Traffic congestion is still a challenge faced by most countries of the world. However, it can be solved most effectively by integrating modern technologies such as Internet of Things (IoT), fog computing, cloud computing, data analytics, and so on, into a framework that exploits the strengths of these technologies to address specific problems faced in traffic management. Unfortunately, no such framework that addresses the reliability, flexibility, and efficiency issues of smart-traffic management exists. Therefore, this paper proposes a comprehensive framework to achieve a reliable, flexible, and efficient solution for the problem of traffic congestion. The proposed framework has four layers. The first layer, namely, the sensing layer, uses multiple data sources to ensure a reliable and accurate measurement of the traffic status of the streets, and forwards these data to the second layer. The second layer, namely, the fog layer, consumes these data to make efficient decisions and also forwards them to the third layer. The third layer, the cloud layer, permanently stores these data for analytics and knowledge discoveries. Finally, the fourth layer, the services layer, provides assistant services for traffic management. We also discuss the functional model of the framework and the technologies that can be used at each level of the model. We propose a smart-traffic light algorithm at level 1 for the efficient management of congestion at intersections, tweet-classification and image-processing algorithms at level 2 for reliable and accurate decision-making, and support services at level 4 of the functional model. We also evaluated the proposed smart-traffic light algorithm for its efficiency, and the tweet classification and image-processing algorithms for their accuracy.