A vehicular ad hoc network (VANET) is a sophisticated wireless communication infrastructure incorporating centralized and decentralized control mechanisms, orchestrating seamless data exchange among vehicles. This intricate communication system relies on the advanced capabilities of 5G connectivity, employing specialized topological arrangements to enhance data packet transmission. These vehicles communicate amongst themselves and establish connections with roadside units (RSUs). In the dynamic landscape of vehicular communication, disruptions, especially in scenarios involving high-speed vehicles, pose challenges. A notable concern is the emergence of black hole attacks, where a vehicle acts maliciously, obstructing the forwarding of data packets to subsequent vehicles, thereby compromising the secure dissemination of content within the VANET. We present an intelligent cluster-based routing protocol to mitigate these challenges in VANET routing. The system operates through two pivotal phases: first, utilizing an artificial neural network (ANN) model to detect malicious nodes, and second, establishing clusters via enhanced clustering algorithms with appointed cluster heads (CH) for each cluster. Subsequently, an optimal path for data transmission is predicted, aiming to minimize packet transmission delays. Our approach integrates a modified ad hoc on-demand distance vector (AODV) protocol for on-demand route discovery and optimal path selection, enhancing request and reply (RREQ and RREP) protocols. Evaluation of routing performance involves the BHT dataset, leveraging the ANN classifier to compute accuracy, precision, recall, F1 score, and loss. The NS-2.33 simulator facilitates the assessment of end-to-end delay, network throughput, and hop count during the path prediction phase. Remarkably, our methodology achieves 98.97% accuracy in detecting black hole attacks through the ANN classification model, outperforming existing techniques across various network routing parameters.