The automotive industry has evolved enormously in recent years, marked by the proliferation of smart vehicles furnished with avant-garde technologies. These intelligent automobiles leverage cutting-edge innovations to deliver enhanced connectivity, automation, and convenience to drivers and passengers. Despite the myriad benefits of smart vehicles, their integration of digital systems has raised concerns regarding cybersecurity vulnerabilities. The primary components of smart cars within smart vehicles encompass in-vehicle communication and intricate computation, in addition to conventional control circuitry. In-vehicle communication is facilitated through a controller area network (CAN), whereby electronic control units communicate via message transmission across the CAN-bus, omitting explicit destination specifications. This broadcasting and non-delineating nature of CAN makes it susceptible to cyber attacks and intrusions, posing high-security risks to the passengers, ultimately prompting the requirement of an intrusion detection system (IDS) accepted for a wide range of cyber-attacks in CAN. To this end, this paper proposed a novel machine learning (ML)-based scheme employing a Pythagorean distance-based algorithm for IDS. This paper employs six real-time collected CAN datasets while studying several cyber attacks to simulate the IDS. The resilience of the proposed scheme is evaluated while comparing the results with the existing ML-based IDS schemes. The simulation results showed that the proposed scheme outperformed the existing studies and achieved 99.92% accuracy and 0.999 F1-score. The precision of the proposed scheme is 99.9%, while the area under the curve (AUC) is 0.9997. Additionally, the computational complexity of the proposed scheme is very low compared to the existing schemes, making it more suitable for the fast decision-making required for smart vehicles.