A centralized approach to solve optimal operation of a practical sized distribution grid with a large number of electric vehicles (EVs) is a computationally challenging task. This work proposes a bi-level hierarchical optimization framework to solve the problem. In the hierarchy, optimal operation of the distribution grid is considered in one level, while the optimal operation of EVs is carried out in another level. The hierarchical optimization framework is based on information exchange among distribution grid control center, EV aggregators, individual EVs, and market operator. The proposed framework consists of detailed mathematical modelling of distribution system components, EVs, and operational constraints. The proposed framework is applied to coordinate charging of hundreds of EVs in the IEEE 34-node three-phase unbalanced distribution system. Case studies demonstrate that the proposed hierarchical optimization framework provides benefits to the distribution grid operations as well as to the individual EV customers.