In this paper, a smart machine-learning-based energy management system (MLBEMS) is developed for a hybrid energy storage system (HESS). This HBESS consists of batteries with high-energy (HE) and high-power (HP) characteristics, to provide grid-supporting services. The aim of the MLBEMS is to improve the overall battery lifetime and achieve state-of-charge (SoC) balancing for two different use cases (UC). UC1 involves enhanced frequency regulation for the Pan-European grid, while UC2 pertains to an electric vehicle (EV) charging station with photovoltaic (PV) generation. The designed MLBEMS is compared with a rule-based energy management system (RBEMS) from the literature with similar use cases. To ensure optimal power sharing between the battery modules, an optimization model is created using real battery aging data. Using a genetic algorithm, optimal power sharing is achieved for various initial SoC conditions. The generated dataset is subsequently utilized to train a machine-learning regression model, and the resulting prediction function is imported into MATLAB/Simulink. In UC1, MLBEMS achieved a 39.3% better SoC balancing compared to RBEMS, along with 36.5% and 22.6% higher battery lifetimes for HE and HP batteries, respectively. Similarly, for UC2, MLBEMS achieved a 68.5% improvement in SoC balancing, along with 53.6% and 45.8% higher battery lifetimes for HE and HP batteries, respectively.