In this paper, an agent based intelligent energy management system is proposed to facilitate power trading among microgrids and allow customers to participate in demand response. The proposed intelligence uses demand response, and diversity in electricity consumption patterns of the customers and availability of power from distributed generators as the vital means in managing power in the system. A new priority index is proposed for customers participating in the market based on frequency and size of load participating in demand response. In order to validate the proposed method, a case study with two interconnected microgrids is simulated. Based on extensive simulation results of the system developed using Java Agent DEvelopment framework (JADE), it has been found that multi-agent based demand response is successful in reducing the system peak in addition to cost benefit for the customers with high priority index.