The swift expansion of Internet of Things (IoT) devices within smart cities necessitates robust security measures to safeguard critical infrastructure and ensure citizen safety. In response, this research presents an advanced deep learning- based anomaly detection system designed to bolster IoT security within the context of smart cities. Leveraging the IoT-23 dataset, our system demonstrates impressive results. One of the system's notable strengths is its adaptability; it generalizes well to diverse datasets and maintains its efficacy in the presence of adversarial attacks. An intuitive user interface facilitates system management and response to detected anomalies, providing a holistic approach to IoT security in smart cities. Positive user feedback affirms the system's usability and satisfaction, emphasizing its practical utility. This research contributes to the broader field of IoT security. It furnishes well-documented code and resources, laying the groundwork for further advancements in this critical domain. As smart cities continue to evolve, the findings and innovations presented in this research serve as a vital step toward ensuring the integrity, privacy, and reliability of IoT networks within urban environments. Lastly, the findings of the experiments show that this technique has an excellent detection performance, with an accuracy rate which is more than 98.7%.