ABSTRACT Nowadays, Mobile Ad hoc Network (MANET) gains more attraction due to its seamless and dynamic use. The existing methods in MANET are plagued by some weaknesses, like higher computation time, undermining their real-time responsiveness. Whereas, lower accuracy in intrusion detection compromises the reliability of these systems, potentially leading to missed threats posing a challenge for effective security measures in dynamic MANET environments. To mitigate these weaknesses, an Auto Metric Graph Neural Network optimized with Woodpecker Mating Algorithm is proposed in this paper for detecting Network Layer Attack in MANET (AGNN-WMA-DNLA-MANET). Initially, the data are gathered from CIC-IDS 2019 dataset. The gathered data undergoes pre-processing to eliminate redundancy and missing values replacement using the Local Least Squares method. Afterward, the preprocessing output is fed to AGNN for classification, which classifies the attack as active, passive, or normal. Then, Woodpecker Mating Algorithm (WMA) is proposed to optimize the AGNN weight parameters to ensure the accurate classification. The proposed technique is executed in NS2 tool. The metrics, like accuracy, false positive rate (FPR) and attack detection rate (ADR), computation time, and RoC is analyzed. The proposed AGNN-WMA-DNLA-MANET approach provides 14.68%, 7.142%, and 4.65% higher accuracy for active attack, 15.19%, 2.77%, and 9.85% higher accuracy for passive attack and 38.18%, 12.02%, and 7.59% better accuracy for normal compared with existing methods, such as Dependable intrusion detection scheme under deep convolutional neural network (DCNN-MANET), deep learning-based intrusion detection scheme for MANET (AE-DNN-MANET), and Benchmarking of machine learning for anomaly based intrusion detection scheme (ML-MANET), respectively.