This research paper deals with the enhancement of Internet of Things (IoT) security through federated ensemble learning (FEI) and adversarial machine learning (AMLI) algorithms. The proposed approach strives to enhance the security of IoT devices and networks against numerous cyber threats. To address the increasing threat of IoT, the study will utilize advanced machine learning techniques in order to build more resilient defenses for IoT networks. Using the IoT-23_Combined dataset, the study scrutinized an array of IoT attack types, revealing the distribution and frequency of different attack categories. The FEI and AMLI models were trained and tested to detect and mitigate these IoT attacks, with the evaluation metrics being accuracy, precision, recall, and F1 score. The FEI model surpassed the AMLI model, registering superior performance in all metrics, with an accuracy of 87.94% and an F1 score of 88.44%. Concurrently, the study recommends the adoption of system hardening strategies and real-time response measures, including robust authentication methods, secure firmware updates, and security awareness training programs. The assessment of these measures was based on their implementation complexity, potential impact on system performance, and adaptability to changing threats. Conclusively, the research findings illustrate the potential of machine learning to bolster IoT security, suggesting a path towards more proactive defense mechanisms and the creation of a resilient IoT ecosystem. This study holds relevance for entities seeking to fortify their IoT security systems against an evolving threat landscape.