With the escalating proliferation of cloud computing services, cloud data center providers are actively in pursuit of solutions not only to curtail energy consumption but also to efficiently cater to the unique demands of their users, thereby enhancing user satisfaction. The process of consolidating virtual machines emerges as a viable strategy for striking a balance between energy consumption and Service Level Agreement violation (SLAv), potentially surmounting this predicament faced by cloud service providers. This study aims to minimize energy consumption and SLAv to their utmost feasible extent by utilizing the First Median Threshold (FMT) technique for physical host selection and virtual machine allocation, in conjunction with the Maximum Ratio of CPU utilization to memory Utilization (MRCU) method for virtual machine selection within the framework of virtual machine consolidation. This dual-pronged approach not only translates into cost savings for cloud providers but also ensures the delivery of optimal services to users. Furthermore, a novel method has been introduced for selecting virtual machines for migration and appropriately choosing physical hosts to achieve equilibrium between two critical parameters: energy consumption and SLAv. The proposed methodology is implemented and evaluated using the CloudSim simulator, utilizing real-world PlanetLab data. The comprehensive analysis of the simulation results reveals that the proposed approach can significantly reduce energy consumption while effectively mitigating SLAv for users.