During recent years, renewable energy resources are gradually recognized as great option in supply side planning of microgrids. This paper focuses on the optimal design, planning, operation, and sizing of hybrid renewable energy based microgrid with the goal of minimizing the lifecycle cost, while considering environmental emission. This paper determine the feasible configuration and component for a microgrid to perform economic and environmental analysis. First, the load profile (such as for lighting, television, electric medical equipment, electric equipment for mosque, and etc. ) consumption of the rural village in 350.59' N, 470.5' in Kurdistan Province of Iran with considering agricultural electricity consumption (electric water pump) is estimated. Then, for supplying the estimated load, four different case studies including, diesel-only, an entirely renewable energy-based, a mixed diesel-renewable , and a grid connected microgrid configuration are designed with the aim of comparing and investigating of their economic, operational performance and environmental emission. Two sensitivity analyses are carried out to find the effects of variation in the inputs and component cost of microgrids; including, change in diesel price, maximum allowable 5% and 10 % unmet energy. For simulation purposes the well-known energy modeling software for hybrid renewable energy systems, HOMER, is used.