A Mobile Ad-hoc Network (MANET) is a self-organizing collection of mobile devices communicating in a distributed fashion across numerous hops. MANETs are an appealing technology for many applications, including rescue operations, environmental monitoring, tactical operations, and so on, because they let people communicate without the usage of permanent infrastructure. This flexibility, however, creates additional security vulnerabilities. Because of its benefits and expanding demand, MANETs have attracted a lot of interest from the scientific community. They do, however, seem to be more vulnerable to numerous attacks that wreak havoc on their performance than any network. Traditional cryptography techniques cannot entirely defend MANETs in terms of fresh attacks and vulnerabilities due to the distributed architecture of MANETs; however, these issues can be overcome by using machine learning approaches-based intrusion detection systems (IDS). IDS, typically screening system processes and identifying intrusions, are commonly employed to supplement existing security methods because preventative techniques are never enough. Because MANETs are continually evolving, their highly limited nodes, and the lack of central observation stations, intrusion detection is a complex and tough process. Conventional IDSs are difficult to apply to them. Existing methodologies must be updated for MANETs or new approaches must be created. This paper aims to present a novel concept founded on deep belief networks (DBN) and long shortterm memory (LSTM) for MANET attack detection. The experimental analysis was performed on the probe, root to local, user to root, and denial of service (DoS) attacks. In the first phase of this paper, particle swarm optimization was used for feature selection, and subsequently, the DBN and LSTM were used for the classification of attacks in the MANET. The experimental results gave an accuracy reaching 99.46%, a sensitivity of 99.52%, and a recall of 99.52% for DBN and LSTM accuracy reaching 99.75%, a sensitivity of 99.79%, and a recall of 99.79%.