This paper proposes a distributed mechanism for energy trading among microgrids in a competitive market. We consider multiple interconnected microgrids in a region where, at a given time, some microgrids have superfluous energy for sale, or to keep in storage facilities, whereas some other microgrids wish to buy additional energy to meet local demands and/or storage requirements. Under our approach, the sellers lead the competition by independently deciding the amount of energy for sale subject to a trade-off between the attained satisfaction from the received revenue and that from the stored energy. The buyers follow the sellers' actions by independently submitting a unit price bid to the sellers. Correspondingly, the energy is allocated to the buyers in proportion to their bids, while the revenue is allocated to the sellers in proportion to their sales. We study the economic benefits of such an energy trading mechanism by analyzing its hierarchical decision-making scheme as a multi-leader multi-follower Stackelberg game. We show that distributing the energy based on a well-defined utility function converges to a unique equilibrium solution for maximizing the payoff of all participating microgrids. This game-theoretic study provides an incentive for energy trading among microgrids in the future power grid.