Cybersecurity in the Internet of Things (IoT) is the practice of implementing measures to secure networks and connected devices from data breaches, cyber threats, and unauthorized access. It is essential owing to the increasing interconnectivity of devices, ranging from smart home appliances to industrial sensors. The potential attack surface expands, necessitating strong cybersecurity measures to protect sensitive data, ensure privacy, and prevent disruptions to critical services with these increasing number of IoT devices. Artificial intelligence (AI) technologies, particularly deep learning (DL) and machine learning (ML) approaches, hold the potential to mitigate and identify cyberattacks on IoT networks. DL demonstrates promise for effectively preventing and detecting security threats within IoT devices. Despite the importance of Intrusion Detection Systems (IDS) in maintaining confidentiality by detecting suspicious activities, classical IDS solutions might face difficulties in the IoT platform. Therefore, this study presents an Artificial Orca Algorithm with Ensemble Learning cyberattack detection and classification (AOAEL-CDC) methodology in an environment of IoT. The presented AOAEL-CDC technique exploited the feature selection (FS) approach with an ensemble learning approach for cyberattack recognition and identification in the IoT atmosphere. In the developed AOAEL-CDC model, the feature selection takes place using the AOA technique. For the cyberattack detection process, the ensemble learning process is carried out by the use of three models such as bidirectional long short-term memory (BiLSTM), gated recurrent unit (GRU), and extreme learning machine (ELM). Finally, the hyperparameter range of the DL techniques takes place using the marine predator's algorithm (MPA). To examine the performance analysis of the AOAEL-CDC methodology, a series of simulations take place using a benchmark dataset. An extensive comparative study reported that the BCODL-SDSC technique reaches an effective performance with other models with a maximum accuracy of 99.31%.