The concept of the Internet Of Things (IoT) is becoming more and more popular in many services and applications of the future. One of the notable fields is the Internet of Medical Things (IoMT). The recognition of IoMT is due to its ability to enable Internet connectivity to smart healthcare systems, thus allowing remote monitoring of patients' health, provisioning assistance, and collecting more information about the patient's health status. However, these innovations come at the cost of security risks due to the high vulnerability of these systems. Therefore, it is crucial to develop effective security mechanisms that will be able to protect the confidentiality and privacy of patient data and prevent unauthorized access and attacks. We propose an intrusion detection system (IDS) that leverages the empirical distribution ranking (EDR) based on the J48 classification algorithm for detecting such attacks. The proposed framework selects the optimal features based on the empirical distributed ranks. The EDR ranks the features according to their importance to the target class. The J48 classifier classifies a new class by creating a decision tree from the selected feature values. The proposed method detected security risks with a high accuracy of 99.33% and a precision of 0.99. The testing time in the WUSTL-EHMS-2020 dataset is 0.04s, which meets the requirements of various IoMT-related applications.