In this paper we present a closed-form solution to the problem of optimally charging a Li-ion battery. A combination of three cost functions is considered as the objective function: time-to-charge (TTC), energy losses (EL), and a temperature rise index (TRI). First, we consider the cost function of the optimization problem as a weighted sum of TTC and EL. We show that the optimal charging strategy in this case is the well-known Constant Current–Constant Voltage (CC–CV) policy with the value of the current in the CC stage being a function of the ratio of weighting on TTC and EL and of the resistance of the battery. Then, we extend the cost function to a weighted sum of TTC, EL and TRI and derive an analytical solution for the problem. It is shown that the analytical solution can be approximated by a CC–CV with the value of current in the CC stage being a function of ratio of weighting on TTC and EL, resistance of the battery and the effective thermal resistance.